MYSQL Query help

I have two tables.

CITY
----
City
a
b
c
d
e

CARS
----
cars | city
honda | a
civic | b
honda | c


I need a query to find cars in each city.

plz help me thaks in advance

regards
rizwan


Comments

  • : I have two tables.
    :
    : CITY
    : ----
    : City
    : a
    : b
    : c
    : d
    : e
    :
    : CARS
    : ----
    : cars | city
    : honda | a
    : civic | b
    : honda | c
    :
    :
    : I need a query to find cars in each city.
    :
    : plz help me thaks in advance
    :
    : regards
    : rizwan
    :
    :
    :
    I don't know sql...

    SELECT * WHERE CARS=a FROM CARS
  • : : I have two tables.
    : :
    : : CITY
    : : ----
    : : City
    : : a
    : : b
    : : c
    : : d
    : : e
    : :
    : : CARS
    : : ----
    : : cars | city
    : : honda | a
    : : civic | b
    : : honda | c
    : :
    : :
    : : I need a query to find cars in each city.
    : :
    : : plz help me thaks in advance
    : :
    : : regards
    : : rizwan
    : :
    : :
    : :
    : I don't know sql...
    :
    : SELECT * WHERE CARS=a FROM CARS
    :
    It should be:
    [code]
    SELECT * FROM CARS WHERE city = "a"; // or city = some_var
    [/code]
    But that only gives you for 1 city. To get all the cities, you'll need to make the city-comparision into a subquery. I haven't come to that part yet.
  • : : : I have two tables.
    : : :
    : : : CITY
    : : : ----
    : : : City
    : : : a
    : : : b
    : : : c
    : : : d
    : : : e
    : : :
    : : : CARS
    : : : ----
    : : : cars | city
    : : : honda | a
    : : : civic | b
    : : : honda | c
    : : :
    : : :
    : : : I need a query to find cars in each city.
    : : :
    : : : plz help me thaks in advance
    : : :
    : : : regards
    : : : rizwan
    : : :
    : : :
    : : :
    : : I don't know sql...
    : :
    : : SELECT * WHERE CARS=a FROM CARS
    : :
    : It should be:
    : [code]
    : SELECT * FROM CARS WHERE city = "a"; // or city = some_var
    : [/code]
    : But that only gives you for 1 city. To get all the cities, you'll need to make the city-comparision into a subquery. I haven't come to that part yet.
    :
    ok, like this?:
    SELECT * FROM CARS ORDER BY city
  • : : : : I have two tables.
    : : : :
    : : : : CITY
    : : : : ----
    : : : : City
    : : : : a
    : : : : b
    : : : : c
    : : : : d
    : : : : e
    : : : :
    : : : : CARS
    : : : : ----
    : : : : cars | city
    : : : : honda | a
    : : : : civic | b
    : : : : honda | c
    : : : :
    : : : :
    : : : : I need a query to find cars in each city.
    : : : :
    : : : : plz help me thaks in advance
    : : : :
    : : : : regards
    : : : : rizwan
    : : : :
    : : : :
    : : : :
    : : : I don't know sql...
    : : :
    : : : SELECT * WHERE CARS=a FROM CARS
    : : :
    : : It should be:
    : : [code]
    : : SELECT * FROM CARS WHERE city = "a"; // or city = some_var
    : : [/code]
    : : But that only gives you for 1 city. To get all the cities, you'll need to make the city-comparision into a subquery. I haven't come to that part yet.
    : :
    : ok, like this?:
    : SELECT * FROM CARS ORDER BY city
    :
    ORDER BY only reorders the query results based on another fields instead of the primary key. It doesn't procedure additional results.
  • : : ok, like this?:
    : : SELECT * FROM CARS ORDER BY city
    : :
    : ORDER BY only reorders the query results based on another fields instead of the primary key. It doesn't procedure additional results.
    :
    Yeah, but isn't that what he wants?
    I don't understand what does he wants?
    Does he want a dynamic 2D array?
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories