INNER JOIN by field content
| From: | José Moreira | Date: | Tue, 25 Jun 2002 13:48:01 +0000 |
| Subject: | INNER JOIN by field content | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-20091@lists.php.net to get a copy of this message | ||
for building my website i am implementing a tree-style data organization.
for that i have a mysql table called 'jm_tree':
CATID, int(10) auto_increment -> Index
PARENT, int(10) ->the CATID of
the 'parent' node
TEXT, varchar(40) -> small
description
TYPE set('FOLDER','FILE','LINK','POST') ->
the type of object
and for each TYPE of object i have a corresponding table like :
ex.: for a TYPE 'FILE' i have a 'jm_files' table [ that has the CATID field
also ( as a FK ) ]
with all the files related to that node.
i want to know is ( and i am perfectly aware that this in possible using
multiple queries and PHP ) if it's possible that in one MySQL query to
INNER JOIN the 'jm_tree' table to the specifical table ( jm_files, jm_links,
fo fo fo )
according to the contents of the 'jm_tree.type'
99%-possibility-of-being-wrong-something-like-example :)
SELECT * FROM jm_tree INNER JOIN jm_files IF jm_tree.type='FILE'
INNER JOIN jm_links IF jm_tree.type='LINKS'
Best Regards,
José Moreira
Técnico de Informática | IT Technician
Vila Nova de Gaia, Portugal
E-mail: jmoreira@e-terno.net
MSN: jose_guedes@hotmail.com
ICQ: 136936120
IRC: gray (irc.ptnet.org)