Error in SQL query in mapbasic

234 views Asked by At

I am writing the query below in MapBasic to insert columns from two tables t1 and t2 into table Sites, but I receive an error that the variable or field t2.CELLID not defined.

Table Sites (Source integer, N integer, LAT float, LONG float) Select t1.CELLID, t2.CELLID, t2.LATITUDE, t2.LONGITUDE from t1 left join t2 on t1.CELLID=t2.CELLID where t1.obj within zone into Sites

Can anyone tell me how to fix it? Thanks.

1

There are 1 answers

0
Md Aslam Khan On

You cannot do a join between a table which is in not in editable mode in this case table is t1 and an editable table which in your case is t2. You first need to save t1 as t11 or any other name you like and open it up again in MapInfo. Once it is opened you can execute your query and it will work for you.

SELECT    t11.cellid,
          t2.cellid,
          t2.latitude,
          t2.longitude
FROM      t11
LEFT JOIN t2
ON        t11.cellid=t2.cellid
WHERE     t11.obj within zone 

Hope it helps !!!