gazetteer.parentgazetteer_guid IS NULL AND
gazetteerlevel.seqno <> '1'
</pre>
This query checks if the child is parent to itself
<pre>
SELECT
gazetteer.gazetteer_guid,
gazetteer.parentgazetteer_guid,
gazetteer.gazetteer_localid,
gazetteer.gazetteername,
gazetteerlevel.seqno,
gazetteerlevel.level
FROM
gazetteer
Inner Join gazetteerlevel ON gazetteer.gazlevel_guid = gazetteerlevel.gazlevel_guid
where
gazetteer.gazetteer_guid = gazetteer.parentgazetteer_guid
</pre>