在我的数据库中,我的列类型= y,类型= x我想查询WHERE type =" xx"并与Like%
结合使用在我的查询中它输入所有数据类型y和x,即使我使用type = x,我如何只显示类型Y
SELECT * from transfer_money
WHERE (type = "x") AND ( title LIKE '%sss@hotmail.com%')
OR ( email LIKE '%sss@hotmail.com%') OR ( name_account LIKE '%sss@hotmail.com%')
ORDER BY created_at DESC
答案 0 :(得分:1)
SELECT
*
FROM transfer_money
WHERE (type = "x")
AND (title LIKE '%sss@hotmail.com%'
OR email LIKE '%sss@hotmail.com%'
OR name_account LIKE '%sss@hotmail.com%')
ORDER BY created_at DESC
答案 1 :(得分:1)
你的括号在错误的地方:
SELECT tm.*
FROM transfer_money tm
WHERE tm.type = 'x' AND
(tm.title LIKE '%sss@hotmail.com%' OR
tm.email LIKE '%sss@hotmail.com%' OR
tm.name_account LIKE '%sss@hotmail.com%'
)
ORDER BY tm.created_at DESC ;
我应该注意,如果您不需要通配符,请删除它们。