Hi Peter,
Yes, it is not possible to join the tables and carry out the required update in a single Update statement. The join needs to be done separately.
For anyone using pre-v17 MapInfo, the leading comma can be removed as follows (going back to the table and column names used in my example):
Select * From pupils Where Catchments Like ",%" Into removeComma
Update removeComma Set Catchments = Right$(Catchments, Len(Catchments)-1)
------------------------------
James Nolet
GIS Manager
Caf Consulting
Mentone office, VIC, Australia
------------------------------
Original Message:
Sent: 12-01-2023 08:31
From: Peter Møller
Subject: Returning multiple spatial results for single row of a table
James,
Your solution added the trick that made it work: joining the table before running the update.
I tried it myself and ran into issues. I couldn't refer back to a column in the point table when building the expression used to update that column.
I ended up with your solution in the SQL Window:
Select a.CombinedName, d.districtnameFrom Addresses As "a", Districts As "d"Where a.Obj Within d.Obj Into _to_updateUpdate _to_update Set CombinedName = IIf(CombinedName = "", districtname, CombinedName + ", " + districtname)
IIf() was added back in MapInfo Pro v17.0.
------------------------------
Peter Horsbøll Møller
Principal Presales Consultant | Distinguished Engineer
Precisely | Trust in Data
------------------------------
Original Message:
Sent: 12-01-2023 08:06
From: James Nolet
Subject: Returning multiple spatial results for single row of a table
Hi Chris,
First, join your two tables together:
Select * from pupils, School_Catchment where pupils.Obj Within School_Catchment.Obj into JoinTable
Then perform the update using the below expression. In the following, 'Catchments' is the name of the new column you have created in the pupil table, and 'Catchment_name' is the column from the school catchments table.
Update JoinTable Set Catchments = Catchments + "," + Catchment_name
The above will place commas at the start of each string. If you are using a later version of MapInfo, you can use IIf for a neater result:
Update JoinTable Set Catchments = IIf(Catchments="",Catchment_name,Catchments + "," + Catchment_name)
(I just saw that Peter got to this before me, but my answer includes the initial table join which might come in handy!)
------------------------------
James Nolet
GIS Manager
Caf Consulting
Mentone office, VIC, Australia