Taking a Access/SQL online class, need help

NedFlanders

New Member
Joined
Mar 8, 2009
Messages
3
I am taking a SQL class where we use Access 2007, and it is an online class.
The instructor is no help so I hope you guys are. The question I have goes like this.....

"Find the book title for each book written by author number 18. Use the IN operator in your query."

Now the book title is in one table, and the author number is in another table. The two tables have no rows or columns in common so I am guessing you use a subquery. This is what I tried...

SELECT TITLE
FROM BOOK
WHERE AUTHOR_NUM IN
(SELECT AUTHOR_NUM
FROM AUTHOR
WHERE AUTHOR_NUM='18';)

I keep getting a box pop up saying ENTER PARAMETER VALUE and AUTHOR_NUM below it where you would type something in.
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
I am taking a SQL class where we use Access 2007, and it is an online class.
The instructor is no help so I hope you guys are. The question I have goes like this.....

"Find the book title for each book written by author number 18. Use the IN operator in your query."

Now the book title is in one table, and the author number is in another table. The two tables have no rows or columns in common so I am guessing you use a subquery. This is what I tried...

SELECT TITLE
FROM BOOK
WHERE AUTHOR_NUM IN
(SELECT AUTHOR_NUM
FROM AUTHOR
WHERE AUTHOR_NUM='18';)

I keep getting a box pop up saying ENTER PARAMETER VALUE and AUTHOR_NUM below it where you would type something in.

I can't answer that specific question, but what do you think this would return ?
Code:
(SELECT AUTHOR_NUM
FROM AUTHOR
WHERE AUTHOR_NUM='18')

if you guess correctly, it makes your homework a lot easier
 
Upvote 0
Can this be true:
The two tables have no rows or columns in common

Surely Books and Authors must be related somehow...Book ID? ISBN Number? Product ID? Author ID? Author Name?

Also:
Beware of text vs. number datatypes. Only the former requires quotes (although in some cases the database engine is kind enough to convert for you anyway).

This is a text criterion (AuthorNum's are text):
Rich (BB code):
Where AuthorNum = '18'

This is a numeric criterion (AuthorNum's are Integers):
Rich (BB code):
Where AuthorNum = 18
 
Last edited:
Upvote 0
I can't answer that specific question, but what do you think this would return ?
Code:
(SELECT AUTHOR_NUM
FROM AUTHOR
WHERE AUTHOR_NUM='18')

if you guess correctly, it makes your homework a lot easier

That should return any AUTHOR_NUM that is represented by the number 18.

Cant you join two tables even if they do not have anything in common by using a subquery?
 
Last edited:
Upvote 0
That should return any AUTHOR_NUM that is represented by the number 18.

let's say I told you to look up the forum_name of all forum members who had the forum name NedFlanders

would you do this ?
Code:
select forum_name 
from forum
where forum_name = 'NedFlanders'
or is there something strange what I'm asking ?
if you did use that query, what forum_name would you get as a result ?

and if you can't get it this time I'll tell you next post :)
 
Upvote 0
let's say I told you to look up the forum_name of all forum members who had the forum name NedFlanders

would you do this ?
Code:
select forum_name 
from forum
where forum_name = 'NedFlanders'
or is there something strange what I'm asking ?
if you did use that query, what forum_name would you get as a result ?

and if you can't get it this time I'll tell you next post :)


Should it be SELECT FORUM_MEMBERS instead of FORUM_NAME?
 
Upvote 0
ah, the point I'm trying to make is that if you already know the person's name is NedFlanders, then there is no reason to look it up

and its the same with AUTHOR_NUM;
(SELECT AUTHOR_NUM
FROM AUTHOR
WHERE AUTHOR_NUM='18')

this query says,
I need to look up the AUTHOR_NUM

for which author ?

for the one that has an AUTHOR_NUM of 18

for which one?

for the one that has an AUTHOR_NUM of 18

and what are you looking for ?

the AUTHOR_NUM

the one with the AUTHOR_NUM that's 18 ?

yes

so you see, if you already know the AUTHOR_NUM is 18, then there is no reason to look it up

so instead of this
SELECT TITLE
FROM BOOK
WHERE AUTHOR_NUM IN
(SELECT AUTHOR_NUM
FROM AUTHOR
WHERE AUTHOR_NUM='18')

you could do this

SELECT TITLE
FROM BOOK
WHERE AUTHOR_NUM IN
( 18 )

because you already know the AUTHOR_NUM is 18, so there is no reason to look up the AUTHOR_NUM
 
Upvote 0
this query says,

Quote:
I need to look up the AUTHOR_NUM

for which author ?

for the one that has an AUTHOR_NUM of 18

for which one?

for the one that has an AUTHOR_NUM of 18

and what are you looking for ?

the AUTHOR_NUM

the one with the AUTHOR_NUM that's 18 ?

yes

James,
Who's on first...?

Ed,
The tables are probably related in some fashion - otherwise it's a strange assignment. If author number is in the books table, that's a common field (key) that creates a relationship. If your still puzzled, post for us:
1) a list of the field names and their data types in the book table
2) a list of the field names and their data types in the author table
3) and for the record, no one would likely use IN for only one criterion although it works. You'd normally just use the equals operator (author number = 18 rather than author number IN (18) )

Alex
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,583
Messages
6,120,383
Members
448,955
Latest member
BatCoder

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top