在数据库中选择语句错误

时间:2015-09-26 21:32:15

标签: php mysql database mysqli

我有一个SELECT语句,但它在MYSQL中给出了一个错误。不知道我做错了什么。

SELECT input, 
CASE WHEN input LIKE %is this to% THEN 10 
ELSE CASE WHEN input LIKE %this to you% THEN 12 
END END 
AS  'matches'
FROM tableName
LIMIT 0 , 30

2 个答案:

答案 0 :(得分:1)

试试这个:

SELECT input,
CASE 
    WHEN input LIKE '%is this to%' THEN 10 
    WHEN input LIKE '%this to you%' THEN 12
ELSE 0
END AS  'matches'
FROM tableName
LIMIT 0 , 30

答案 1 :(得分:0)

SELECT input 
CASE WHEN input LIKE '%is this to%' THEN 10 
  ELSE
    CASE WHEN input LIKE '%this to you%' THEN 12 
  END 
END 
AS  'matches'
FROM tableName
LIMIT 0 , 30

请注意'(单引号)