Page 1 of 1

how compare string to integer in query

Posted: Wed Feb 23, 2011 6:31 pm
by tcloud
I want to perform a query which returns a subset of the fields in a mySQL table.

A query like this:

Code: Select all

$query = mysql_query("SELECT * FROM table WHERE name LIKE 's%'") ;
returns all names which begin with 'S'.

But if I make this query:

Code: Select all

$query = mysql_query("SELECT * FROM table WHERE code LIKE '3%"') ;
only returns about a dozen of the values 3, 30-39, 300-399, etc. (The field is VARCHAR and contains numerals.)

How can I accomplish this query?

thanks,
Tom

Re: how compare string to integer in query

Posted: Thu Feb 24, 2011 3:09 am
by VladSun
I really cant understand what you are asking...
Can you post some example data and the expected result?