Query

Van “maak eens een leesbare query”:

SELECT tblObjects.object_ID, tblObjects.object_OT, tblObjects_LayoutstringGroup_Parent.object_ID AS parentObj,
tblLayoutStringGroups_Parent.layoutStringGroup_code AS parent, tblObjects_LayoutstringGroup.object_ID AS groupObj,
tblLayoutStringGroups.layoutStringGroup_code, tblLayoutStrings.layoutString_ID, tblLayoutStrings.layoutString_layoutStringGroup_ID,
tblLayoutStrings.layoutString_code, tblLayoutStringGroups.layoutStringGroup_parent_ID
FROM tblLayoutStrings INNER JOIN
tblLayoutStringGroups ON tblLayoutStrings.layoutString_layoutStringGroup_ID = tblLayoutStringGroups.layoutStringGroup_ID INNER JOIN
tblLayoutStringGroups tblLayoutStringGroups_Parent ON
tblLayoutStringGroups.layoutStringGroup_parent_ID = tblLayoutStringGroups_Parent.layoutStringGroup_ID INNER JOIN
tblObjects ON tblLayoutStrings.layoutString_ID = tblObjects.object_ID INNER JOIN
tblObjects tblObjects_LayoutstringGroup ON tblLayoutStringGroups.layoutStringGroup_ID = tblObjects_LayoutstringGroup.object_ID LEFT OUTER JOIN
tblObjects tblObjects_LayoutstringGroup_Parent ON
tblLayoutStringGroups_Parent.layoutStringGroup_ID = tblObjects_LayoutstringGroup_Parent.object_ID
WHERE (tblLayoutStrings.layoutString_code LIKE ‘%settings%’)

…terwijl achteraf natuurlijk

select object_ID from tblObjects where object_OT=’LSG’ and object_ID not in (select layoutstringgroup_id from tblLayoutstringGroups)

genoeg was.

update: ik bedoelde precies het omgekeerde:

select * from tblLayoutStringGroups where layoutStringGroup_ID not in (select object_id from tblObjects where object_OT=’LSG’)

Must-read-weblog entries! 🙂