PHP SQL, SELECT corresponding data from 3 tables at once?
- by user346325
I have 3 tables, 'u' 'd' 's'
'u' has
userid
divid
'd' has
divid
divname
's' has
sname
primaryuserid
secondaryuserid
Now what I'd like to do is display a table with rows of the following format
userid, divname, sname
Plus figure out a way to decipher whether userid is a primary or secondary for this sname table.
I'm able to show userid and divname using a left join, but I don't know how I would add a third table? To make it trickier, there can be more than 1 snames for each userid, up to ~20. Is there a way to display 0-20 snames depending on the userid, seperated with commas?