从一个表中检索多个记录

时间:2013-03-28 03:26:10

标签: php

我有一张显示兴趣的表格。每个兴趣都有一个ID。目前,查询只会将一个人带回一个ID。它基本上是网站上的过滤器,按兴趣对结果进行排序。

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

我希望它显示多个兴趣的结果。

所以在我的基本逻辑中,它看起来像这样

$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) ";

但显然这不起作用。

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:0)

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

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