Re: MySQL join with variable table?
| From: | Jason Wong | Date: | Tue, 18 Nov 2003 07:51:49 +0000 |
| Subject: | Re: MySQL join with variable table? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-31609@lists.php.net to get a copy of this message | ||
On Tuesday 18 November 2003 10:00, Jason Godesky wrote:
> In a MySQL database, I have several tables, including one central table
> that essentially keeps track of the records in the other tables.
>
> TABLE1
> +---------------+---------------+---------------+
>
> | id | str | val1 |
>
> +---------------+---------------+---------------+
>
> | 123456789 | "TABLE2" | 987654321 |
>
> +---------------+---------------+---------------+
>
> TABLE2
> +---------------+---------------+
>
> | id | val2 |
>
> +---------------+---------------+
>
> | 123456789 | "j00 r0xx0r" |
>
> +---------------+---------------+
>
> Currently, I'm selecting all the records for a given entry with two SELECT
> statements, one to the central table which gives me the name of the second
> table. My question is, is there any way to do this in a single query with
> a join? I suspect not, but I wanted to see if anybody on this list had
> any ideas before I give up on the possibility entirely.
But why are you storing the tablenames in a "central table"? Maybe I'm too
stupid but I can't see any advantage in doing so. And in doing so you're
creating that little problem for yourself.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
------------------------------------------
/*
Fashions have done more harm than revolutions.
-- Victor Hugo
*/