0

我有这个 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',制作 % 任何文本?

4

3 回答 3

1

编辑以回应您的评论:

我会用一个CASE声明。就像是

ORDER BY CASE WHEN Department LIKE '% - Chair' THEN 1 WHEN Department = 'Alternative Education' THEN 2 ELSE 3 END

您可以根据需要在 CASE 语句中添加任意数量的 WHEN 语句。

于 2013-02-16T02:23:11.260 回答
0

您尝试过部门 Not Like '%Chair%

于 2013-02-16T02:23:12.833 回答
0

在这种情况下使用 SQL like 运算符。

试试这个:

Department NOT LIKE '% - Chair'
于 2013-02-16T02:27:48.977 回答