You need to look up LEFT JOIN in the documention of the database you are
using.


> 
> "Andy" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > Hi there,
> >
> > I do have a sql statement where I could need some help on.
> >
> > There are 3 tables: provinces, cities, countries
> > The result should be city, province, country but only if province is
> > available. If not just display city and country.!
> >
> > Lets say we are searching for madrid.
> >
> > I did build following statement:
> >      SELECT c.city, c.ID, p.province, co.country FROM 
> cities c, provinces
> p,
> > countries co WHERE c.city like 'madrid%' AND p.province_id 
> = c.province_id
> > AND p.country_code = c.country_code AND c.country_code = 
> co.country_code
> > ORDER BY country , province limit 0, 10
> >
> >
> > Works fine as long as there is a province for this city. But
> unfortunatelly
> > my db does not have for all countries provinces. But there 
> is a madrid in
> > spain.
> > so I would like to change this querry to return madrid in 
> spain even if
> the
> > province is unknown, but also if the province exists (in 
> this case with
> the
> > name of the province)
> >
> > Maybe there is a way to do if statements in sql??
> >
> > Thanx for any help
> >
> > Andy
> >
> >
> >
> 
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

Reply via email to