PDA

View Full Version : trying to get info. for just one city??



bullet
02-23-2008, 01:26 PM
I have a table setup.It is a business listing.
The table is set up like this.
State, city, business, address, url, zip code, phone


What I am trying to do is get is all the businesses from one City. So I will as for help on this.

SELECT `Louisiana`.`business`, `Louisiana`.`City`
FROM Louisiana
ORDER BY `Louisiana`.`business` ASC, `Louisiana`.`City` ASC

This will give me a list of business in Louisiana with a list of all the cities in Louisiana.
I need to get the businesses in one city.
I will use this. I need to get all the businesses in my table for Baton Rouge, Louisiana. It can't be hard, but I am a beginner and having problems with this.
thanks for the help.

Basil
02-23-2008, 01:38 PM
SELECT (coumns) FROM (table) WHERE City = 'something' ORDER BY etc.

bullet
02-23-2008, 02:07 PM
Thanks for helping.

This is still giving me all cities and businesses in Louisiana.

redsox9
02-23-2008, 03:10 PM
Post your code here so we can see what you have.

bullet
02-23-2008, 04:06 PM
I have a table setup.It is a business listing.
The table is set up like this.
State, city, business, address, url, zip code, phone


What I am trying to do is get is all the businesses from one City. So I will as for help on this.

SELECT `Louisiana`.`business`, `Louisiana`.`City`
FROM Louisiana
ORDER BY `Louisiana`.`business` ASC, `Louisiana`.`City` ASC

This will give me a list of business in Louisiana with a list of all the cities in Louisiana.
I need to get the businesses in one city.
I will use this. I need to get all the businesses in my table for Baton Rouge, Louisiana. It can't be hard, but I am a beginner and having problems with this.

This is my first post. I have my code and the way my database is setup. I know I need a where clause, but I can't figure out how and what to say. I say it wrong everytime.
Blue is the way my database is. and red is my code.
Thanks for the help

felgall
02-23-2008, 04:59 PM
SELECT `Louisiana`.`business`, `Louisiana`.`City`
FROM Louisiana
WHERE `Louisiana`.`City` = cityname
ORDER BY `Louisiana`.`business` ASC

bullet
02-24-2008, 08:15 AM
It looks like to have to do the select function and then the where clause to get this code to work right?

felgall
02-24-2008, 11:32 AM
That is all one select statement

bullet
02-24-2008, 08:37 PM
Yes it is one select statement, but you have to do the select and then do the where clause. I did not under stand to do both.
Thanks I hope I get it.

felgall
02-24-2008, 09:17 PM
See http://www.felgall.com/db2sel.htm for a decription of all the possible parts that a SELECT statement can have.