SELECT `blah` FROM `FriendsList` JOIN (`Profile`, `Pictures`) ON (Pictures.ID = FriendsList.IDFriend AND Profile.ID = FriendsList.IDFriend) WHERE FriendsList.ID='1'
The problem is that it's returning 0 rows, although the Friends List table does contain 2 records with the ID 1
SELECT *
FROM 'FriendsList'
INNER JOIN Profile ON Profile.ID=FriendList.IDFriend
INNER JOIN Pictures ON Pictures.ID=FriendList.IDFriend
WHERE FriendList.ID='1'
raghavan20 wrote:look at timv's example, that is how you should be forming join. Your join has basic faulty syntax.
Each join should have an individual statement.
Sorry for the lack of my knowledge on the other possible JOIN syntax.
You can use left join, if you want to list rows, only if there are matching rows in the joining table and it is upto the developer to choose which logic he/she should follow.
select
*
from table1
left join table2 on
table2.a = table1.b
so what happens now is, each row from table1 is checked with rows of table2 and if table2.a = table1.b, the row will be listed depending on the columns specified in the select.
SELECT *
FROM 'FriendsList'
INNER JOIN Profile ON Profile.ID=FriendList.IDFriend
INNER JOIN Pictures ON Pictures.ID=FriendList.IDFriend
WHERE FriendList.ID='1'
This will go and find that have equal ids in each field you listed ... i swear I'm crap at explaining SQL, anything else I can just about sort it out . Your best bet is to try them out, and see the outcome.