Home  >  Q&A  >  body text

php - database reading

It is known that the database has a table called dati, and a field title format is varchar, and the stored content is Chinese sentences of different lengths. How should it be written to output long sentences first and then short sentences? ?
I can’t achieve it by using select *from dati order by title! Ask God for help

迷茫迷茫2683 days ago361

reply all(3)I'll reply

  • 阿神

    阿神2017-05-16 13:17:20

    SELECT * FROM dati ORDER BY LENGTH(title) DESC

    The length of a string can also be calculated in MySQL. First calculate the length of the string, and then arrange it backwards according to the length, and you can achieve it

    reply
    0
  • 为情所困

    为情所困2017-05-16 13:17:20

    select *from dati order by length(title);

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-05-16 13:17:20

    Arranged in descending order by length

    reply
    0
  • Cancelreply