简体   繁体   English

从一个表中检索多个记录

[英]retrieve multiple records from one table

I have a table that displays interests. 我有一个显示兴趣的表格。 Each interest has an ID. 每个兴趣都有一个ID。 At the moment the query just brings back one person for one ID. 此刻查询只带回一个人一个ID。 Its basically a filter on the website that sorts the results by interests. 它基本上是网站上的过滤器,可按兴趣对结果进行排序。

$catwhere = " and e.person_id IN (select escint_person from person_interests_person where escint_person = e.person_id and escint_interest = 26) ";

I would like it to display the results from multiple interests. 我希望它显示来自多个兴趣的结果。

So in my basic logic it would look like this 所以按照我的基本逻辑,它看起来像这样

$catwhere = " and e.person_id IN (select escint_person from person_interests_person where escint_person = e.person_id and escint_interest = 26,27,28,29) ";

but obviously this doesn't work. 但显然这是行不通的。

Any help would be appreciated. 任何帮助,将不胜感激。

您需要在第二个查询中使用IN子句。

where escint_person = e.person_id and escint_interest IN( 26,27,28,29 )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM