how compare string to integer in query

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
tcloud
Forum Newbie
Posts: 6
Joined: Fri May 07, 2010 6:11 am

how compare string to integer in query

Post 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
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: how compare string to integer in query

Post by VladSun »

I really cant understand what you are asking...
Can you post some example data and the expected result?
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply