Re: INNER JOIN by field content
| From: | szii at sziisoft dot com | Date: | Tue, 25 Jun 2002 19:41:52 +0000 |
| Subject: | Re: INNER JOIN by field content | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-20099@lists.php.net to get a copy of this message | ||
You need to have "keys" in each table to join them together.
Once you have those "keys" in place, you can match the keys
across the tables and use a WHERE clause to filter the results.
'Luck!
-Mike
----- Original Message -----
From: "José Moreira" <jmoreira@e-terno.net>
To: "Php-Db" <php-db@lists.php.net>
Sent: Tuesday, June 25, 2002 6:48 AM
Subject: [PHP-DB] INNER JOIN by field content
> 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)
>
>
--------------------------------------------------------------------------------
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php