0

likeとaまたはを使用してクエリを作成しました

select * from xxx where title like ('%bon%') or title like ('%test%')

結果を受け取る:bonjour je test bonjour test bonjour test

そして、タイトルの単語数で並べ替えたい:bonjour je test test bonjour bonjour test

私はnamedQueriesでGrailsを使用しています。

それを行うことは可能ですか?

ありがとう

4

1 に答える 1

0

この小さなトリックを使用して、スペース文字の数を数え、それで並べ替えることができます。

select * from xxx where title like ('%bon%') or title like ('%test%')
order by (LEN(title) - LEN(REPLACE(title, ' ', '')))
于 2011-02-23T13:02:13.633 に答える