MySQL joins table if question exists
I have a database with a table config
. This table can be a table config_cstm
associated by an identifier with 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 will check for the existence of an existing table in PHP. I would like to do it all in one MySQL statement.
Any suggestions?
a source to share
You are talking about "my DB", but in my experience, usually in a given DB, the table exists or does not exist. Are you trying to apply the same query to multiple parallel DBs?
If so, I think there may be other, more serious structural differences, and as Satanic Puppy says, you would be much better off constructing your query in PHP or another pre-SQL language rather than trying to prepare a query that will fit all forms.
a source to share