SELECT * FROM cms_nodes
LEFT JOIN cms_settings ON setting_node_id = node_id
LEFT JOIN cms_junctions ON junction_setting_node_id = node_id AND junction_node_id = 0

WHERE 
	( node_id = :node_id OR ISNULL( :node_id ))
AND 
	( node_parent_node_id = :node_parent_node_id OR ISNULL( :node_parent_node_id ))
AND
	( node_type = 'setting' OR node_id = 0 )

ORDER BY node_ordering
# :ids