Jump to content

Help MYSQL UNION not querying correctly


Techmate

Recommended Posts

The problem that I am having is rather simple it seems but I am a little stumped I have been working on it for 2 days now  :-\. As you see below it querys 217 two times and I just need it to query all the results only once. Any idea why???

 

SELECT id id, cast.booked  booked

FROM images, cast WHERE id = cast.memberid AND posterid =  '51' 

UNION 

SELECT memberid id, images.booked booked

FROM cast,images WHERE posterid='51'  AND null !='' ORDER BY id ASC

id  |    booked

---------------

217

217 yes

218

219 yes

Link to comment
https://forums.phpfreaks.com/topic/267533-help-mysql-union-not-querying-correctly/
Share on other sites

You're welcome, and I'm glad I could help.

 

Though, please use explicit JOIN statements, not implicit ones like the above. Doing it the right way will make the query a lot easier to read, and thus maintain. Saving you a lot of future headaches.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.