Reputation: 45
I just began studying MySQL and ran into error 1064. It's a basic and short snippet. Please help, I've tried googling for about an hour now. I come to you as a last resort.
select distinct(b.publisher), c.name
from customer c, orders o, book b
where c.name = 'Park' and
c.custid = o.custid and b.bookid = o.bookid;
My question is that while above code works, if I put c.name in front of distinct(b.publisher), I get a 1064. Any help would be appreciated. Thank you!
Upvotes: 0
Views: 46
Reputation: 10206
The purpose of DISTINCT is to eliminates doubles rows, meaning the exact same data in all your returned columns.
If you have several columns in your SELECT clause, you can NOT have DISTINCT on one column only. And this is the reason of your error 1064
Thus you should do either
select distinct b.publisher, c.name
or
select distinct b.publisher
which is the exact same as
select distinct(b.publisher)
Upvotes: 1