Hi there,
I am trying to use sql such as this:
SELECT t.*, t2.* FROM templates t
LEFT JOIN IF(t.t_type = 0,'templates_email',
IF(t.t_type = 1,'templates_sms','templates_fax')) t2
ON t.t_id = t2.t_id;
Is it possible to do something like that?
basically I want to join on one of three tables based on the value from the row.
Is this recommended if it is possible?
update
So,
basically the templates
table is the table that contains all the information that every template must have, eg name, id, description
then you have the templates_x
tables these tables contain the fields that are unique to each template type.
(There are quite a few and having a single table with null fields for those not applicable is not practical).
The tables are called templates_x
however the appropriate x is stored in the templates table as an int flag.
The join between the templates_x
tables and the templates
table is through the t_id
.
So what do you suggest?