I'm trying to write a query which does this (in semi-english):
select t.*, s.*
from templates t, skins s
where t.templateTitle is either 'first_tpl_name' or 'second_tpl_name' or 'third_tpl_name'
and t.skinId is in (skin with skinId of 1's parentSkinIds field: field will be list of ids seperated by a ,)
and s.skinId is in (same as above)
... i think that's it...
it may be hard to understand but it's the best I can do.
Basically i want to select all data from templates and skins, but only select templates where the template titles are the same as some presets, and only select templates and skins records where the skinId is IN ( the record where skinId=1's parentSkinIds field).
Basically this will allow me to have skin trees, where minor changes to skins can be branched off using the template set belonging to the parent skin, but with a few changes (e.g. a different colour scheme)
GreenWithSparkles
/
Blue Green
\ /
SuperSkin OtherSkin
\ /
B A S E S K I N
^ ^ ^ this is a diagram of what i'm aiming for, where if, for example, a template in GreenWithSparkles skin is empty, it will try and get the template from green skin, and if it is empty there it will try superskin and so on. Obviously quite a bit of PHP logic is required here.
I need the parentSkinIds field to be set for each skin because this should avoid me selecting every template/skin in the database (e.g. to get greenwithsparkles, blue and otherskin will definitely not be needed - we don't want to select them).
If you can think of a better way of doing this, please let me know.
I can't think of a way to structure this query. Is it even possible? I'd be very glad of help in this area - SQL is my weak point.