SQL 选择数组中的所有内容
我的作业有一个问题,例如有一个类别数组 $cat=array('1','4','5','7');现在我需要根据类别从数据库中选择产品
SELECT * FROM products WHERE catid='1'
SELECT * FROM products WHERE catid='4'
SELECT * FROM products WHERE catid='5'
SELECT * FROM products WHERE catid='7'
是否可以在单个查询中执行此操作?因为四个查询的最终结果将被合并。
My homework has a problem for example there is a category array $cat=array('1','4','5','7'); now i need to select products from db based on the category that is
SELECT * FROM products WHERE catid='1'
SELECT * FROM products WHERE catid='4'
SELECT * FROM products WHERE catid='5'
SELECT * FROM products WHERE catid='7'
Is it possible to do this in a single query? as the final results of the four queries will be combined.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
更新:(简短版本并更新缺少的逗号)
Update: (a short version and update missing comma)
它更通用,适合任何阵列!
It's more generic and will fit for any array!!