[FWTools] sql string functions for shapefiles in ogrinfo
Mateusz Loskot
mateusz at loskot.net
Fri Jan 12 02:47:12 EST 2007
Bryan Keith wrote:
> Hello,
>
> I can use this command and get the output I expect from a shapefile:
>
> ogrinfo "myfile.shp" -al -sql "select * from 'myfile' where ID = 'SB-18'"
>
> However, what if I want all records where ID starts with 'SB'? If I
> tried left, substr and others e.g.:
>
> where left(ID,2) = 'SB'
>
> I assume if you're using a db like PostGIS then the sql is parsed by the
> db, and you can read the db documentation for the sql syntax. Which sql
> syntax reference should I be using for shapefiles?
SQL query compiler in OGR supports SQL standard operators: LIKE, ILIKE,
IS, IN, etc.
So, you can write your query as follows:
"select * from myfile where ID LIKE 'SB%'"
Cheers
--
Mateusz Loskot
http://mateusz.loskot.net
More information about the FWTools
mailing list