0

I'm trying to select record from Table 1 which has more than one kind of 'Type' in Table 3. There is no common ID between Table 1 and Table 3. But Table 2 has LID that's common to LID in Table 1. Table 2 has SLID that's common to SLID in Table 3.

The query should only select A and C from Table 1 without joining any tables. I can easily do this with python but I need to be able to do this with definition query and without any join.

enter image description here

I know the following query is not correct but I tried variations of it using Group and Count but no luck so far.

LID in (SELECT LID FROM Table1 WHERE LID in (SELECT LID FROM Table2 WHERE SLID in (SELECT SLID FROM Table3 WHERE Type in (SELECT Type FROM Table3 ) GROUP BY LID HAVING COUNT(Distinct Type)>1)))

  • The only way you're going to have any luck with this is to load the shapefiles / tables into QGIS and use the DB manager to do the join on the tables and query the features you want to add using SQL... the layer definition query doesn't have these capabilities that I know of... – DPSSpatial Jun 26 '17 at 20:45
  • I can do this in layer definition query too but only after joining. I was hoping to do without the join. – user99819 Jun 26 '17 at 20:54
  • 1
    What GIS software are you using? – PolyGeo Jun 26 '17 at 21:46
  • I'm using ArcMap's Layer Definition Query. – user99819 Jun 27 '17 at 16:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy