Lid |
|
Mijn eerste google resultaat leverde mij dit op, hier staat een voorbeeld:
SELECT c.contentid, c.contenttext, u.name
FROM content c, users u
WHERE c.contentid = $cntntid
AND c.userid = u.userid
Note that c.contentid = $cntid part in the WHERE clause is like you would use in retrieving data from one table. ($cntid is just a PHP variable - you may replace it by any value, that is hard code it or pass it by any other means).
Now, what compromises of a join? Yes, the c.userid = u.userid joins these two tables. The result of the query is that it will fetch content id and content text is picked up from 'content' table and author name is picked up from 'users' table.
I have assumed a lot many things above, but if you want something specific, please do ask.
bron:
http://www.asta...12815.html
Een ander voorbeeld:
SELECT * FROM shoes AS sh, colours AS col, shoes_colurs AS shc WHERE sh.Id = shc.Shoe AND col.Id = shc.Colour ORDER BY sh.Name ASC |