not sure the mysql is going to do that for you.
What you need to do now is to display the table with php with a litte
checking.

Dispay first state and store that in a variable e.g. prev_state
then in subsequent iterations check to see if present state equals
previous state, if not display present state

----------------------------
Get first state and city
Display state 
Display city
assign state to prev_state

while (not end of table)
 get state and city
 if prev_state!=present_state
   display state
 end if 
 prev_state=present_state
 display city
end while
--------------------------------


Hope that helps...

--- In [email protected], "William Watson" <[EMAIL PROTECTED]>
wrote:
>
> Hey everybody...
> 
> I have an issue getting this sub query stuff to work. I have done 
> loads of research and still can't find exactly what I need, or even 
> partially what I need to do the following:
> 
> I have a table called "locations". Within this table, I have various 
> fields, though the ones I am working with per this dilemma are "city" 
> and "state". There are a lot of cities 
> e.g. "Daytona","Destin","Orlando", etc.) which are in the same state 
> (e.g. Florida). I am working with various other city/state 
> combinations as well. In other words, I will need to know how to 
> build a query to pull all states from the "locations" table and list 
> the cities under those states like I have it laid out in Example 2 
> below.
> 
> My current query makes the results look like this (showing the state 
> several times instead of only one time):
> 
> Example 1:
> 
> ALABAMA
> - Huntsville
> ALABAMA
> - Montgomery
> ALABAMA
> - Talladega
> 
> CALIFORNIA
> - Los Angeles
> CALIFORNIA
> - Sacramento
> CALIFORNIA
> - San Diego
> 
> FLORIDA
> - Daytona
> FLORIDA
> - Destin
> FLORIDA
> - Orlando
> 
> I am trying to create a query to get the results to look like this 
> (showing each state only once instead of several times, and list all 
> cities underneath their corresponding state, in ascending order):
> 
> Example 2:
> 
> ALABAMA
> - Huntsville
> - Montgomery
> - Talladega
> 
> CALIFORNIA
> - Los Angeles
> - Sacramento
> - San Diego
> 
> FLORIDA
> - Daytona
> - Destin
> - Orlando
> 
> etc, etc.
> 
> I don't have another table that is storing the cities, separate from 
> the states. Is this the problem? Can anybody explain to me what I 
> need to do to make up a query that will work to output the results 
> like I need them? I greatly appreciate any assistance and/or code you 
> can provide to help me.
> 
> T-H-A-N-K-S!!!
> 
> - William
>


Reply via email to