0

I'm fairly adept with the SQL Select in MapInfo, but I'm running into something that's got me a bit stumped.

I've got data in two tables that have a few columns in common. I want to join the tables and export them to a CSV, but I don't want to duplicate those columns. Unfortunately, something like this doesn't work:

SELECT table1.*, table2.A, table2.B, table2,C 
  From table1, table2 
  Where table1.match = table2.match 
  Into table_merged`

Is there a way to accomplish this? If it helps, table2 will always have the same number of columns and the first five columns are present in table1.

1
  • This sounds like a nested query. You'd have to create your join selection, and then wrap it as the from clause of another selection statement that listed the columns you wanted. I have no idea if MapInfo supports such nested queries or not. – Chris W Jun 12 '15 at 0:18
1

I see what you are asking for. Unfortunately the MapInfo SQL syntax doesn't support "tableA.*". You can only select all columns from both tables or specific columns.

I see three workarounds

  1. Select all columns and then modify the table structure afterwards where you can remove the extra columns you don't want

  2. If your table structure is somewhat static, you could create a SQL Select statement and save this to a SQL Select Template via the SQL Select dialog.

  3. Via MapBasic you can figure out dynamically which columns to include and from this create a SQL statement only including the necessary columns in your SQL statement.

'----

On the Pitney Bowes Ideas Portal a wish similar to your exists, give it a like: http://ideas.pb.com/ideaView?id=08780000000E75VAAS

1
  • Thanks. Those were the three possibilities I'd arrived at and was hoping to avoid. I've been doing the first, but will probably attempt the third. – sphenodont Jun 12 '15 at 19:36

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.