Have 2 table
1st {id_city,name } 2nd table {id_ctz,name,sname,age,id_city}
need selected full information (name(city),name,sname,age) people with same name ascending by age?
Have tried:
select city.name,citizen.name,age from citizen,city where city.id_city = citizen.id_city and citizen.name = '%s' order by age asc
input variable is name
Advertisement
Answer
I’m guessing that you want all rows to be returned, and you want people with some name first, sorted by age. Afterwards you want all other rows. This query will do that:
SELECT city.name, citizen.name, citizen.age FROM citizen JOIN city ON city.id_city = citizen.id_city ORDER BY citizen.name <> 'some_name', citizen.age