Welcome Guest, Not a member yet? Register   Sign In
Mysql get values from table with join (or and) ?
#2

Hi,

Try this (if i understood you correctly)

// Query for b1
SELECT * FROM messages m1 JOIN buddies b on b.b1=m1.userid and status=1

// Query for b2
SELECT * FROM messages m2 JOIN buddies b on b.b2=m2.userid and status=1

// Query for all messages
SELECT * FROM messages m1 JOIN buddies b on b.b1=m1.userid and status=1
UNION ALL
SELECT * FROM messages m2 JOIN buddies b on b.b2=m2.userid and status=1
Reply


Messages In This Thread
RE: Mysql get values from table with join (or and) ? - by aurelien - 02-26-2015, 04:46 AM



Theme © iAndrew 2016 - Forum software by © MyBB