MySQL Join a Table if Exists Question
Posted
by swhitlow
on Stack Overflow
See other posts from Stack Overflow
or by swhitlow
Published on 2010-04-26T20:42:49Z
Indexed on
2010/04/26
20:53 UTC
Read the original article
Hit count: 148
I have a DB which has a table called "config". This table could possibly have a "config_cstm" table that is related by the id to the config table.
I was wondering - is there a way to dynamically check for the existence of this table in one simple select statement?
In other words, something like:
"select * from config (IF EXISTS config_cstm THEN LEFT OUTER JOIN config_cstm ON config.id = config_cstm.id_c"
I know how I would go about checking for the existence of an existing table in PHP. I was wanting to do this all in one MySQL statement though.
Any suggestions?
Thanks!
© Stack Overflow or respective owner