Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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
add comment

1 Answer

Agnes

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.

Peter

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
add comment

Your Answer

 
discard

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.