Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
MySQL Multiple-Table Query Question?
I am supposed to list the book codes for each pair of books that have the same price. The first book_code listed should be the major sort key and the second book_code should be the minor sort key. They give an example of a pair being Book_Code 0200 and 7599 because both books are $8.00 for this problem.
I am not even sure how to really start this because it sounds simple enough yet I am sure it is more complicated than I am thinking it is going to be.
Here is an example of the coding I have for a different problem so that you guys can see what the tables and columns are called...
select Book_Code, Title, Price
from Book
join Publisher on Publisher.Publisher_Code = Book.Publisher_Code
where Publisher.Publisher_Code = 'PL';
It did not work, it gave me an error saying that Column Book_Code in field list is ambiguous....
1 Answer
- The EskimoLv 41 decade agoFavorite Answer
select distinct Book_Code, Price
from Book b1, Book b2
where
b1.Publisher_Code <> b2.Publisher_Code and
b1.Price = b2.Price
This should work!
It lists all pairs (sets) of books that have the same price.
P.S. select price also from the table so that Book_Code will be from b1 and Price will be from b2 though b1.price will be same as b2.price. Think it will work now!
select distinct Book_Code, Price
from Book b1, Book b2
where
b1.Publisher_Code <> b2.Publisher_Code and
b1.Price = b2.Price