2015-09-22 75 views
0

我想查找帶有條件的請求中最後一個字符的所有單詞。LIKE不工作後沒有進入

我的查詢是:

SELECT `name` FROM `cities` WHERE 
(SELECT `name` FROM `cities` WHERE LIKE '%а') 
AND 
WHERE `name` NOT IN (SELECT `game_code` FROM `games` WHERE game_code LIKE 'qaZxsw2wewewqRRE') 

但是,這仍然無法正常工作。

+4

'AND NOT IN' .... and * what * not in? – Lamak

+0

看起來像查詢語法是錯誤的。 – rajuGT

+1

您錯過了條款 –

回答

2

試試這個:

SELECT `name` FROM `cities` WHERE 
`name` LIKE '%а' 
AND 
`name` NOT IN ('qaZxsw2wewewqRRE') 

你並不需要:

(SELECT `game_code` FROM `games` WHERE game_code LIKE 'qaZxsw2wewewqRRE') 

,因爲它只會返回一個DISTINCT值是'qaZxsw2wewewqRRE'因爲它並沒有結束,這將不會影響任何東西在不結束於a'%a'

所以真的你只需要:

SELECT `name` FROM `cities` WHERE 
`name` LIKE '%а'