Re: [sqlite] Query returns all rows

2006-09-25 Thread drh
"Igor Tandetnik" <[EMAIL PROTECTED]> wrote:
> David Champagne
>  wrote:
> > If I have a table defined in the following manner
> >
> >CREATE TABLE License (Form varchar(256), Type int, NbOcc int)
> >
> > and then I execute a query
> >
> >SELECT * FROM License WHERE FORM = "form";
> >
> > I get all rows returned
> 
> "form" in double quotes is an alternative way to refer to FORM column - 
> it is _not_ a string literal. So your query condition is WHERE 
> FORM=FORM, which is of course always true (except maybe when FORM is 
> NULL).
> 
> A string literal should be enclosed in single quotes, as in 'form'.
> 

Furthermore, the column name "form" is easily confused with the
SQL keyword "from".  You might want to consider selecting a more
distinctive name for that column.  
--
D. Richard Hipp   <[EMAIL PROTECTED]>


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Query returns all rows

2006-09-25 Thread Paolo Vernazza

David Champagne wrote:

If I have a table defined in the following manner

CREATE TABLE License (Form varchar(256), Type int, NbOcc int)

and then I execute a query

SELECT * FROM License WHERE FORM = "form";

I get all rows returned, even though I only want the rows where the
column FORM contains the string "form".  Any idea if this is a problem
in the definition of the query or a bug in SQLite?

I am using SQLite version 3.2.2

Thanks

The query you are looking for is

SELECT * FROM License WHERE FORM = 'form';

Strings should be enclosed with single quote.

Double quoted strings are interpreted as column names; if there isn't a column with that name, then they are interpreded as strings. 


Paolo


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Query returns all rows

2006-09-25 Thread Mark Richards
I would tend to avoid mixed case and never use all upper case to specify 
anything (other than when defining a constant perhaps).  Your use of 
case between "FORM" and "Form" as example.


Also the use of the term "Type" for a fieldname (or variable) may be 
stretching reserved words a bit.  For that matter, I'd suspect "FORM" or 
"Form" as well.  Note your query says FORM but the fieldname is Form.


I bet something got munged as above to produce this.  Your table also 
has no primary key.  Could this be an index problem?  Did you define 
one?  What data did you populate in the fields?


Or, there must be something obvious I've overlooked.

/m


David Champagne wrote:

If I have a table defined in the following manner

CREATE TABLE License (Form varchar(256), Type int, NbOcc int)

and then I execute a query

SELECT * FROM License WHERE FORM = "form";

I get all rows returned, even though I only want the rows where the
column FORM contains the string "form".  




-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Query returns all rows

2006-09-25 Thread Doug Currie
Monday, September 25, 2006, 1:46:12 PM, David Champagne wrote:

> and then I execute a query

> SELECT * FROM License WHERE FORM = "form";

> I get all rows returned

Try:

SELECT * FROM License WHERE FORM = 'form';

e

-- 
Doug Currie
Londonderry, NH


-
To unsubscribe, send email to [EMAIL PROTECTED]
-