Jump to content

union select. different amount of rows


Jaynesh

Recommended Posts

Hi,

 

I'm already using a join on each query. Will it still work? Can I add an OR to merge both queries?

 

For e.g

 

SELECT user.id, post.id

FROM user

LEFT JOIN

ON user.id = post.id

 

OR

 

SELECT vote.id, vote.up, vote.down

FROM vote

Link to comment
Share on other sites

Hello

 

Ok, i've done that but it isnt working.

 

SELECT DISTINCT dbPosts.post
FROM dbPosts

LEFT JOIN ( dbUsers, dbFriends )
ON (
dbPosts.username_id = dbUsers.id
AND (dbPosts.username_id = dbFriends.user_id)
OR
(dbPosts.username_id = dbFriends.friend_id))

LEFT JOIN (dbUsers, dbPosts_share, dbFriends)
ON (
dbPosts.username_id = dbUsers.id
AND 
(dbPosts.post_id = dbPosts_share.post_id)
OR 
(dbPosts.username_id = dbPosts_share.user_id)
AND
(dbPosts_share.user_id = dbFriends.friend_id)
OR 
(dbPosts_share.user_id = dbFriends.user_id))

Link to comment
Share on other sites

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.