MySQL join with variable table?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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.

--
Jason Godesky
jason@xxxxxxxxxxxxxx
http://www.tribaldawn.com/jason/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux