mySQL中如何匹配多个字段
我试图将 forum_id 与几个不同的 forum_id 相匹配,例如 forum_id = 5,7,12,43,63,78
我目前有以下代码:(
SELECT topic_title, topic_id, forum_id
FROM $MYSQL_TOPIC
WHERE topic_title
LIKE '%%%s%%'
AND forum_id = 5
LIMIT 50
使用 mysql_real_escape_string 和 sprintf)
我尝试过:
forum_id = 5 OR 7
forum_id = 5|7
forum_id = 5 AND 7
forum_id = 5 & 7
但没有一个会匹配它们,因此搜索所有这些。
Im trying to match forum_id with several different forum_id's, something like forum_id = 5,7,12,43,63,78
I currently have this code:
SELECT topic_title, topic_id, forum_id
FROM $MYSQL_TOPIC
WHERE topic_title
LIKE '%%%s%%'
AND forum_id = 5
LIMIT 50
(using mysql_real_escape_string and sprintf)
I tried:
forum_id = 5 OR 7
forum_id = 5|7
forum_id = 5 AND 7
forum_id = 5 & 7
But none of them will match them all and therefore search though them all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
forum_id IN (5,7,12,43,63,78)
forum_id IN (5,7,12,43,63,78)