im breaking my head for about two hours, need a query to get the custom templates from the "template" table. what it needs to do, is a inner join that gets all templates which names doesn't exist in the master style (styleid -1). that's what I was able to come up with :/
Code:
SELECT t1.templateid, t1.styleid, t1.title, t2.styleid, t2.title
FROM template AS t1, template AS t2
WHERE t1.templatetype = 'template' AND t2.templatetype = 'template'
AND (t1.styleid <> -1 AND t1.title <> t2.title AND t2.styleid = -1)
AND NOT (t1.styleid = -1 AND t1.title = t2.title AND t2.styleid = -1)
GROUP BY t1.templateid, t2.title
ORDER BY t1.title