SQL Query problem

410 views
Skip to first unread message

Thomas Halbrook

unread,
Jan 3, 2012, 10:55:07 AM1/3/12
to MapInfo-L
Hello Listers,
 
I know this issue has been brought up many times but I can't seem to find where my exact problem is addressed.
I am trying to select all objects within the ILEC_ADDR table that are within All_DSL_regions or within _24K_DSL_RANGES.
 
The following is my SQL query;
 
Select * from ILEC_ADDR,All_DSL_regions, _24k_DSL_RANGES
where ILEC_ADDR.obj Within All_DSL_regions.obj Or ILEC_ADDR.obj Within _24k_DSL_RANGES.obj into Selection
 
"No join specified between tables ILEC_ADDR and All_DSL_Regions, invalid join condition in where clause"
 
How can I correct the query to accomplish my objective?
 
Thanks,
 
Tom Halbrook

Data Directions

unread,
Jan 3, 2012, 5:23:29 PM1/3/12
to mapi...@googlegroups.com

Tom,

 

At a guess, try adding parenthesis around the “where” condition. Even though an “OR” has the lowest precedence, MapInfo may be getting confused. So try:

 

(ILEC_ADDR.obj Within All_DSL_regions.obj) Or (ILEC_ADDR.obj Within _24k_DSL_RANGES.obj)

 

Hmmm, just noticed you are using three tables. As such you may have to run two separate queries:

 

Select * from ILEC_ADDR, All_DSL_regions

where ILEC_ADDR.obj Within All_DSL_regions.obj into Selection

 

and then

 

Select * from ILEC_ADDR, _24k_DSL_RANGES

where ILEC_ADDR.obj Within _24k_DSL_RANGES.obj into Selection

 

Regards,

 

Bill

--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en

Lars I. Nielsen (GisPro)

unread,
Jan 4, 2012, 1:00:14 AM1/4/12
to mapi...@googlegroups.com
Hi Thomas,

You cannot use OR in a join clause. Pro only handles INNER joins, and OR designates a cross/outer join.

MapInfo needs an inner join clause for all tables, which are a number of "tabA.colB = tabC.colD" type clauses with AND between.

E.g. (for three tables): tabA.colB = tabC.colD AND tabC.colE = tabF.colG

More clauses can be added also using AND (an OR'ed clause can be put inside parantheses.

I.e. JoinClause AND MoreClauses, with MoreClauses perhaps being "(tabA.ColX = 123 or tabC.colY < 567)".

It can be a bit tricky, as this form obscures the difference between join and filter conditions, which is why a "new" form has been invented in SQL. Unfortunately Pro still uses the "old" form.



Glædelig Jul / Happy Yule time
Kind regards / Med venlig hilsen
Lars I. Nielsen
GIS & DB Integrator
GisPro

©

 

GisPro støtter Julemærkefonden

GisPro supports the Danish Christmas Seal

http://www.e-julemaerket.dk

Thomas Halbrook

unread,
Jan 10, 2012, 11:46:09 AM1/10/12
to MapInfo-L
Thanks Bill and Lars for your valuable input.
Reply all
Reply to author
Forward
0 new messages