我读过很多关于NOT IN运算符的Q& A’
If I use IN operator to filter NULL values and white spaces It is not working Why?
还有很多其他问题,但问题是当我们在运算符中不使用非主键时,它不会返回响应.
If I use IN operator to filter NULL values and white spaces It is not working Why?
还有很多其他问题,但问题是当我们在运算符中不使用非主键时,它不会返回响应.
SELECT * FROM temp_customers WHERE temp_customers.fk_my_id NOT IN (SELECT fk_my_id FROM customers)
其中fk_my_id是非主键,可能是一个字符串.
有什么想法吗?
在这里使用group_concat用逗号分隔fk_my_id
原文链接:https://www.f2er.com/php/135224.htmlSELECT * FROM temp_customers WHERE temp_customers.fk_my_id NOT IN (SELECT GROUP_CONCAT(fk_my_id) FROM customers) # when fk_my_id is INTEGER output (1,2) SELECT * FROM temp_customers WHERE temp_customers.fk_my_id NOT IN (SELECT GROUP_CONCAT("'",fk_my_id,"'") FROM customers) # when fk_my_id is VARCHAR output ('1','2')