mysql查询,选择某个结果数组 [英] mysql query, selecting a certain array of results

查看:44
本文介绍了mysql查询,选择某个结果数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个 ID 列表,例如:

We have a list of IDs, for example:

11, 22, 55, 99, 187

我们有一个带有id"字段的表.

We have a table with a field "id".

我们基本上想要选择 id 等于 11, 22, 55, 99, 187

We basically want to select ALL results where the id equals 11, 22, 55, 99, 187

执行这样的 mySQL 查询的最佳方法是什么?

What would be the best way to do a mySQL query like this?

而不是做 WHEREid='11' OR '22'.....

我们在 PHP 中使用它,因为我们有一个 ID 列表,并且想要通过 mysql 查询使用这些 ID 来选择结果.

We are using this with PHP, as we have a list of IDs and are wanting to select the results using these IDs with a mysql query.

推荐答案

使用这个

Where id IN (11,22,55,99,187)

这篇关于mysql查询,选择某个结果数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆