Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/56.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 以类似的方式逐案订购_Mysql_Sql_Sql Order By - Fatal编程技术网

Mysql 以类似的方式逐案订购

Mysql 以类似的方式逐案订购,mysql,sql,sql-order-by,Mysql,Sql,Sql Order By,这是有效的SQL语句吗 select title from table order by case when title like "%string%" then 0 else 1 end asc 如果我使用title=“string”我会得到有效的结果。 我如何更改它以使其接受%string% select title from table order by case when title regexp "string" then 0 else 1 end asc; 我没有将其设置为^st

这是有效的SQL语句吗

select title
from table
order by case when title like "%string%" then 0 else 1 end asc
如果我使用
title=“string”
我会得到有效的结果。 我如何更改它以使其接受%string%

select title
from table
order by case when title regexp "string" then 0 else 1 end asc;
我没有将其设置为
^string
,因为您正在搜索
%string%

我没有将其设置为
^string
,因为您正在搜索
%string%


它是语法上有效的语句。如果
title=“string”
返回正确的结果-没有理由使用其他内容您想逐字匹配
%string%
?仅供参考,like子句中的
%
充当通配符Yes我想与wild匹配card@ChasingDeath
title REGEXP“^string”
确实有效!请把它写在回答中。你试过你贴的东西吗?这有什么不对?它是语法上有效的语句。如果
title=“string”
返回正确的结果-没有理由使用其他内容您想逐字匹配
%string%
?仅供参考,like子句中的
%
充当通配符Yes我想与wild匹配card@ChasingDeath
title REGEXP“^string”
确实有效!请把它写在回答中。你试过你贴的东西吗?有什么问题吗?它比像“%string%”这样的
标题更糟糕,而它做的工作完全相同。它比像“%string%”这样的
标题更糟糕,而它做的工作完全相同