MySQL concat不退出条件

时间:2018-10-18 17:26:54

标签: mysql

这有效

SELECT USERID, FNAME, LNAME FROM USERS WHERE CONCAT(FNAME, ', ', LNAME, ', ', EMAIL) LIKE CONCAT('%', REPLACE(?, ' ', '%'), '%', '%')"

但我要添加此内容

TBL USERS 

USERID   FNAME    LNAME    EMAIL 
1        JONE      DEO     tes@doe.com
2        JANE      DEO     tes1@deo.com
3        Jow       DEO     tdb@deo.com


TBL MSG 

MSGID    RECEIVED    READ 
1        YES         YES 
2        NO          NO 
3        NO          NO 

这是我的尝试

SELECT USERID, FNAME, LNAME FROM USERS WHERE CONCAT(FNAME, ', ', LNAME, ', ', EMAIL) LIKE CONCAT('%', REPLACE(?, ' ', '%'), '%', '%' WHERE NOT EXISTS ( SELECT * FROM MSG WHERE 
RECEIVED = 'YES' AND  READ = 'YES' ))"

所以我只想选择在“接收(是)并读取(是)”下不退出的用户

0 个答案:

没有答案