Topic: Fetching data from three tables.

I'm trying to fetch data from three tables with one single query, but I haven't really succeeded.

I've tried:

SQLsats = "SELECT gastbok.gID, gastbok.inlagg, gastbok.skickat, members.id, members.user, members.kon, members.inloggad, members.alder, "
SQLsats = "members.bor, members.land, bilder.path FROM gastbok INNER JOIN (members INNER JOIN bilder "
SQLsats = "ON (gastbok.fran = bilder.id)) ON gastbok.fran = members.id WHERE gastbok.till = " & Request.QueryString("id") & " ORDER BY gID DESC LIMIT 200"

and

SQLsats = "SELECT gastbok.gID, gastbok.inlagg, gastbok.skickat, members.id, members.user, members.kon, members.inloggad, members.alder, "
SQLsats = "members.bor, members.land, bilder.path FROM gastbok, members, bilder "
SQLsats = "WHERE (gastbok.fran = bilder.id) AND (gastbok.fran = members.id) AND gastbok.till = " & Request.QueryString("id") & " ORDER BY gID DESC LIMIT 200"

but all I get is errors. Seeing as I get them, I am doing something awfully wrong. This is my first time doing joins on more than two tables :/

Re: Fetching data from three tables.

SELECT bla FROM table INNER JOIN table2 ON condition INNER JOIN table3 ON condition ... ... WHERE ...

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: Fetching data from three tables.

Teehee, I didn't paste my original query which was correct:

SQLsats = "SELECT gastbok.gID, gastbok.inlagg, gastbok.skickat, gastbok.antalinlagg, members.id, members.user, members.kon, members.inloggad, members.alder, "
SQLsats = "members.bor, members.land, bilder.path FROM gastbok INNER JOIN members ON gastbok.fran = members.id INNER JOIN bilder "
SQLsats = "ON gastbok.fran = bilder.id WHERE gastbok.till = " & Request.QueryString("id") & " ORDER BY gID DESC LIMIT 200"

But can you see where I went wrong? I was pulling my hair seeing as it wouldn't work...but if you look at it it's pretty obvious that would generate a faulty query :D