简体   繁体   中英

retrieve multiple records from one table

I have a table that displays interests. Each interest has an ID. At the moment the query just brings back one person for one 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 )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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