Since you gave no real details of your table structure, I'll conjecture. Assume city table and advert table is defined as:
CREATE TABLE city ( city_id int not null, auto_increment, city_name varchar(50) default "" ) CREATE TABLE adverts ( ad_id int not null auto_increment, ad_text varchar(200) default "", city_id int not null ) SELECT c.city_name, a.ad_text FROM adverts a LEFT JOIN city c using(city_id) ORDER BY city; This will list every advert. Where an advert has no city. the city_name will display as NULL. To find cities with no adverts: SELECT c.city_name, a.ad_text FROM city c LEFT JOIN adverts a using(city_id) ORDER BY city; -----Original Message----- From: Ivan Balazs [mailto:[EMAIL PROTECTED]] Sent: Monday, February 04, 2002 6:26 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] query from two tables Hi! The situation: I have 2 tables in an adverising site. In one table, i have the cities used by advertisers, and in the other there are the ads.This ad table has a field which refers to the id of the city in that table. The problem: what mysql method should i use if i want to order the query by cities? I have tried multiple selection like select ads.*, cities.* from ads, cities , but it returns a nonsense. Any help would be appreciated Balazs -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php