select query issue

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
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

select query issue

Post by itsmani1 »

need help in query

Code: Select all

select name form test where name = [first letter is a]
for example if name is :

Calgary, AB
Opelika, AL
Miami, FL

then it should show

Opelika, AL and Calgary, AB as both start with A

any help.

thanks
Last edited by itsmani1 on Fri Dec 08, 2006 5:03 am, edited 1 time in total.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

select name from test where name < 'b'
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Re: select query issue

Post by timvw »

itsmani1 wrote:need help in query

Code: Select all

select name form test where name = [first letter is a]
for example if name is :

Calgary, AB
Opelika, AL
Miami, FL

then it should show

Opelika, AL and Calgary, AB as both start with A
They don't start with A. They start with O and C.

The problem is that you've stuffed two values in the same column (city and state). Assuming that you're lucky and there are not city names with a comma in there name you could select WHERE name LIKE '%, A%'.
Post Reply