Page is a not externally linkable
- Code, Content, and Presentation
-- Databases
---- Ignore empty fields on join


JamieBrown - 4:34 pm on Jul 28, 2008 (gmt 0)


I think you might be looking for a LEFT JOIN. When you list your tables like that you're essentially doing an INNER JOIN. If you write out the syntax for a LEFT JOIN manually it should work.

Something like:

FROM players INNER JOIN villages ON villages.player = players.id LEFT JOIN tribes ON tribes.id = players.ally

Watch out for LEFT JOINs on big tables though - they can be slow and resource intensive. If its data you need to use really regularly you can break some normalisation rules every now and again, as long as you do it carefully!

Jamie.


Thread source:: http://www.webmasterworld.com/databases_sql_mysql/3709352.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com