On 5/19/08, Skip Evans <[EMAIL PROTECTED]> wrote:
> Hey all,
>
>  Here's the table definition:
>
>  CREATE TABLE bsp_options (
>  optionsID INTEGER NOT NULL PRIMARY KEY,
>  modelID INT(11) NOT NULL,
>  startyear INT(11) NOT NULL,
>  endyear INT(11) NOT NULL,
>  options TEXT NOT NULL,
>  productcodesize VARCHAR(10),
>  productdesc VARCHAR(200),
>  pattern VARCHAR(10) );
>
>  The insert statement that creates the records looks like this:
>
>           $sql="INSERT INTO bsp_options
> (modelID,startyear,endyear,options,
> productcodesize,productdesc) VALUES
>                          ($modelID,
>                          ".$arr[3].",
>                          ".$arr[4].",
>
>  '".sqlite_escape_string($arr[5])."',
>                          '".$arr[7]."',
>                          '".$arr[6]."')";
>

The above is too messy. How can you even read that code with all the
quotes? Use bind params instead. They are much easier to manage and to
read.


>  After this statement is used in a loop that inserts 14,000 records I can
> see in SQLiteAdmin there are dozens of records that fit the criteria.
>
>  SELECT * FROM bsp_options WHERE startyear=1990
>
>  Produces no results.
>
>  SELECT * FROM bsp_options WHERE startyear='1990'
>
>  Produces no results.
>
>  SELECT * FROM bsp_options WHERE startyear like '1990%'
>
>  Produces results!!!
>
>  Is it treating the data like a string? Why is the like qualifier working???

Because you have something after 1990, most likely an empty space. Try
the following statement --

SELECT '_' || startyear || '_'
FROM bsp_options
WHERE startyear LIKE '1990%'

You results may look like so

_1990 _

Notice the empty space after 1990?



>  --
>  Skip Evans
>  Big Sky Penguin, LLC
>  503 S Baldwin St, #1
>  Madison, WI 53703
>  608-250-2720
>  http://bigskypenguin.com
>  =-=-=-=-=-=-=-=-=-=
>  Check out PHPenguin, a lightweight and versatile
>  PHP/MySQL, AJAX & DHTML development framework.
>  http://phpenguin.bigskypenguin.com/
>


-- 
Puneet Kishor http://punkish.eidesis.org/
Nelson Institute for Environmental Studies http://www.nelson.wisc.edu/
Open Source Geospatial Foundation (OSGeo) http://www.osgeo.org/
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to