MYSQL 查询返回多个用户输入参数的行数
我有一个数据库设置来跟踪错误,有一个配置文件表来跟踪谁是谁,还有一个错误表包含所有错误的信息。我对每个表感兴趣的字段是:
profiles表:
userid | realname
---------------
1 | Bob
2 | Alice
4 | Carol
...
bugs表:
id | reporter | short_desc
-----------------------------
1 | 1 | short description 1
2 | 2 | short description 2
3 | 1 | short description 3
4 | 3 | another short description
其中profiles.userid = bugs.reporter,bugs.id是特定bug的ID
我正在用PHP制作一个自动报告创建器,最终将最终出现在 Joomla 的 Plotalot 中,这意味着它必须是一个查询。自动报告的用户可以指定他想要在报告中显示的人员的用户 ID。即:
enter IDS: 1,4
reporter | bugs
--------------
Bob | 2
Carol | 1
该数据库有超过 5,000 个错误和 400 个活跃贡献者。有没有什么方法可以构造一个查询来返回类似格式的结果,而无需为每个记者使用 union select?
非常感谢
I have a database setup to track bugs, with a profiles table to keep track of who's who, and a bugs table which contains the information on all of the bugs. The fields i'm interested in each table are:
profiles table:
userid | realname
---------------
1 | Bob
2 | Alice
4 | Carol
...
bugs table:
id | reporter | short_desc
-----------------------------
1 | 1 | short description 1
2 | 2 | short description 2
3 | 1 | short description 3
4 | 3 | another short description
where profiles.userid = bugs.reporter, and bugs.id is the id of the specific bug
I'm making an automated report creator in PHP that will eventually end up in Plotalot for Joomla, which means it has to be one query. The user of the automated report can specify what userid's of the people he wants to show up in the report. ie:
enter IDS: 1,4
reporter | bugs
--------------
Bob | 2
Carol | 1
The database has over 5,000 bugs and 400 active contributors. Is there any way to construct a query to return results formatted like that without using union select for each reporter?
Many Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这可能会起作用:
This might do the trick: