Home  >  Q&A  >  body text

How to retrieve records sorted by or in sql statement

For example, this related article statement:

SELECT * FROM zbp_post WHERE log_Type = '0' AND log_Status = '0' AND ((1 = 1) AND ( log_Tag LIKE '%{155}%' OR log_Tag LIKE '%{3}%' OR log_Tag LIKE '%{8}%' ) ) LIMIT 10 OFFSET 0

I want to take out the tag 155 first, then the tag 3, and then the tag 8

But the result of this statement is messy. It is not the result I want.

How can I get the sorting result I want, thank you!

咔萌琪服饰咔萌琪服饰1536 days ago1101

reply all(1)I'll reply

  • 知本

    知本2020-08-17 16:02:08

    zbp_post There should be a sorting field in this table, please look for it. Before adding to the limit statement, order by field name desc (sort from large to small) or asc (sort from small to large)

    reply
    0
  • Cancelreply