[gdal-dev] shapefile->mysql join problem

William Kyngesburye woklist at kyngchaos.com
Fri Dec 12 13:12:38 EST 2008


I trying to do a shapefile to mysql join:

ogrinfo -al -so -sql "SELECT * FROM st99_d00 LEFT JOIN  
'MYSQL:mydb 
,host=localhost,user=me,password=,tables=state_sum'.state_sum ON  
st99_d00.state = state_sum.stfips" st99_d00.shp

This works if the state_sum.stfips field is not indexed at all, or has  
a non-unique index.  But when I use a primary key or unique index (the  
stfips field IS unique), I get an error:

ERROR 1: SQL: Unrecognised secondary field st99_d00.state in JOIN  
clause..


Intended behavior?  Bug?  Or I'm doing it wrong?  I suppose if some  
form of index works, though not unique, the lookup won't be slow.

Note that this is really for a mapserver mapfile, but since it doesn't  
work directly in OGR I'm asking here.

DATA "SELECT * FROM st99_d00 LEFT JOIN  
'MYSQL:mydb 
,host=localhost,user=me,password=,tables=state_sum'.state_sum ON  
st99_d00.state = state_sum.stfips"

-----
William Kyngesburye <kyngchaos*at*kyngchaos*dot*com>
http://www.kyngchaos.com/

"Time is an illusion - lunchtime doubly so."

- Ford Prefect




More information about the gdal-dev mailing list