我有这个MySQL查询:
$query = mysql_query("SELECT * FROM school_staff WHERE DELETED = 'NO' AND BUILDING = '$building' ORDER by
Department != 'Principal',
Department != 'Assistant Principal',
Department != 'Kindergarten',
Department != 'First Grade',
Department != 'Second Grade',
Department != 'Third Grade',
Department != 'Fourth Grade',
Department != 'Fifth Grade',
Department != 'Learning Support',
Department != 'Alternative Education',
Department != '% - Chair',
Department ASC") or die(mysql_error());
如何制作该行:Department != '% - Chair',
以使%任何文字?
答案 0 :(得分:1)
编辑以回应您的评论:
我会使用CASE
语句。像
ORDER BY CASE WHEN Department LIKE '% - Chair' THEN 1 WHEN Department = 'Alternative Education' THEN 2 ELSE 3 END
您可以根据需要在CASE语句中添加尽可能多的WHEN语句。
答案 1 :(得分:0)
您是否尝试过部门不喜欢'%主席%
答案 2 :(得分:0)
在这种情况下使用SQL like运算符。
试试这个:
Department NOT LIKE '% - Chair'