A suggestion:
 
Rather than having to create columns of the correct data type for a particular query and then update them with the particular _expression_, create a permanent dummy column in the base tables, say MIJ as logical data type (or something small).
 
Then ...
 
Select ... from tab1, tab2 where tab1.mij=tab2.mij and tab1.fld1=tab2.fl1 + tab2.fld2 ....
 
The dummy columns and _expression_ will then always overcome the "no join specified..." problem (which appears to be an artifact of an early design decision - performance?).
 
Don't index mij as the extra i/o in checking the index is just overhead in this case.
 
---------------------------------------------------------------------------------
 
I do like MapInfo's SQL. Just found recently for those wishing to squeeze the last bit of performance (or functionality), that an SQL such as:
 
Select ... from tab1[,tab2] where .... and cust_function(acol1,acol2,..) ....
 
can have cust_function as external (DLL-resident). Also, (as is stated in the MB manual) cust_function can replace standard functions such as cos, abs etc.
 
So if you had quite a bit of logic in cust_function or prefer to write in something other than MapBasic when you have a choice, write cust_function in c, Delphi or similar. In combination with MITAB library, would be possible to pass rowid's and read and process objects as part of the comparison. Using some of the ideas here (http://www.spatialprojects.com.au/spatialsql_custfns.htm , esp pt 8.) , it may be possible to update tab1 or tab2 (or another tab on the fly). "may be" because I know its possible to update tab1,tab2 within MapBasic, but not sure if an external update operation on the same table would work - havent tested that yet. If the SQL was prefaced with a save, it most likely would work as the MI select is only reading, so no transaction files would exist.
 
---------
 
Dreams:
 
Now what would be nice is a statement to attach the MapBasic window to the address space of one (or more!) particular (dormant) MB app with all the declarations (and possibly code) and then write SQLs such as the one above in MapInfo Pro.
 
eg. Someone writes a nice "IsParallel(l1obj,l2obj)" function for 2 lines, which could be declared in an app and accessed from any MI Pro SQL.
 
Great opportunity for commercial MB authors OR a MapInfo community (wiki) app could receive those hidden gems accumulated over the last 15 yrs and trapped in purpose-built apps. I suggest this would increase the power of MapInfo SQL n-fold in a short space of time. Also, some major new features in basic functions in MI Pro might shift all those users who are sitting on "the last really useful update"  (for me v6.5). 
 
 
 
Phil.
 

_______________________________________ 


Email : [EMAIL PROTECTED]
Web: www.spatialprojects.com.au
Skype: PhilWaight

 
 
----- Original Message -----
Sent: Friday, September 01, 2006 10:26 PM
Subject: RE: [MI-L] Complex SQL Joins

Hi Evan,

I don't think MapInfo allows you to combine columns or to use functions when creating a join.  It hasn't worked for me in the past.

You could try creating a new column and populating it with either Table2.state+Table2.community in Table2 or Right$(Table1.cmtyno,4) in Table1, and then do a join using this new column.

Don

Message: 1
Date: Thu, 31 Aug 2006 10:00:58 -0700
From: "Evan MacDougall" <[EMAIL PROTECTED]>
Subject: [MI-L] Complex SQL Joins
To: <mapinfo-l@lists.directionsmag.com>
Message-ID:
<[EMAIL PROTECTED]>
Content-Type: text/plain; charset="us-ascii"

I am trying to join two tables in MapInfo where there isn't a column-to-column match.  In Oracle SQL I can do a join on substrings of a panel or on a joint _expression_ of two columns matched to one.
However, when I try this in MapInfo it gives me an error about my join not being valid.

 

Table1 cmtyno (char 6) = Table2 state (char 2) + Table2 community (char 4).

 

So I try this as my join:

 

Table1.cmtyno = (Table2.state+Table2.community)

 

MapInfo throws me an error saying it's an invalid join.

 

Then I try this as my join:

 

Right$(Table1.cmtyno,4) = Table2.community

 

This also causes MapInfo to give me and error about an invalid join.

 

Is it possible to join these two tables without creating new columns?
Am I just getting my syntax wrong or have I found a limitation in MapInfo?

 

-Evan MacDougall

GIS Supervisor

Nationwide TotalFlood Services Inc. (NTSI)

(a wholy owned subsidiary of Capital Title Group)

[EMAIL PROTECTED]

(800)736-3109 x3681

"Gentlemen, we may not make history tomorrow, but we shall certainly change the geography."

 
_______________________________________________
MapInfo-L mailing list
MapInfo-L@lists.directionsmag.com
http://www.directionsmag.com/mailman/listinfo/mapinfo-l

Reply via email to