Write an SQL statement table "company"
Id city top
1 Beijing, Shanghai Beijing
2 Jinan, Shijiazhuang Jinan
3 Beijing
Sorting rules:
1. search "Beijing" to list "Beijing" in "city;
2. there is "Beijing's top" in the 'top ";
3. arrange 'id' from large to small
Reply to discussion (solution)
50 more points. that's all. please help me.
Less than 100 points. please help me
Don't wait online. if you want to get the score, contact me for the 15403255
Select * from company where city like '% Beijing %' and top like 'Beijing' order by id desc union select * from company where city like '% Beijing %' and top not like' beijing 'Order by id desc
Select * from company where city like '% Beijing %' and top like 'Beijing' order by id desc union select * from company where city like '% Beijing %' and top not like' beijing 'Order by id desc
This is not what I want.
Try this. the test is acceptable.
SELECT * FROM testWHERE city LIKE '% Beijing %' order by (top LIKE '% Beijing %') DESC, id DESC
The table name is not changed. change test to company.
Try this. the test is acceptable.
SQL code
?
123456
SELECT * FROM test WHERE city LIKE '% Beijing %' order by (top LIKE '% Beijing %') DESC, id DESC
Positive solution