Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

what is wrong with this statement? I recon the where-clause is the problem.

Select * from "BEDIRECT_POT_" + vo_num, PLZ5_2012_bereinigt 
where "BEDIRECT_POT_" + vo_num.PLZ like PLZ5_2012_bereinigt.PLZ 
order by PLZ 
into "BEDIRECT_POT_" + vo_num + "_PLZ"

This section seems to be wrong: "BEDIRECT_POT_" + vo_num.PLZ

Thanks for your help. a.

share|improve this question


There might be a couple of things wrong with your statement:

Dynamic SQL statements

Running a SQL Select like this would either involve Alias variables or the use of Run Command to run the SQL Select statement as a string.

Try this:

Dim sTab As String
Dim aCol As Alias
sTab = "BEDIRECT_POT_" + vo_num
sCol = sTab & ".PLZ"

Select * 
   from sTab, PLZ5_2012_bereinigt 
   where aCol = PLZ5_2012_bereinigt.PLZ 
   order by aCol
   into "BEDIRECT_POT_" + vo_num + "_PLZ"

Note that I replaced the Like operator with =.

or this:

Dim sTab As String
Dim sCmd As String
sTab = "BEDIRECT_POT_" + vo_num

sCmd = "Select * "
   & " from " & sTab & ", PLZ5_2012_bereinigt" 
   & " Where " & sTab & ".PLZ = PLZ5_2012_bereinigt.PLZ" 
   & " Order by " & sTab & ".PLZ"
   & " into "BEDIRECT_POT_" + vo_num + "_PLZ"

Run Command sCmd

Join operator

You can't join using the Like operator in MapInfo Professional/MapBasic, so you need to use another operator.

I have switch from Like to = in the examples above.


share|improve this answer
Bit rusty on my Mapbasic :) – Nathan W Jun 11 '13 at 11:19
Yeah, I guess you need to train your MapBasic muscle a bit again, Nathan ;-) – Peter Horsbøll Møller Jun 11 '13 at 11:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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