Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.