我想一次从数据库表中搜索两个或多个值

时间:2017-08-28 09:53:30

标签: php html mysql

我正在做一个项目,我需要使用复选框包含多个搜索。这是一个查询,我可以一次获得单个值 search / 1 。我需要将值设为 search / 1& 2 等...

 $query = $conn->query("SELECT id FROM " . DB_ACCOUNTS . "
        WHERE height LIKE _utf8'%$searchQuery%' collate utf8_general_ci  OR ethnictype LIKE _utf8'%$searchQuery%' collate utf8_general_ci OR bodybuild LIKE _utf8'%$searchQuery%' collate utf8_general_ci OR skincolor LIKE _utf8'%$searchQuery%' collate utf8_general_ci  
        AND (id IN (SELECT id FROM " . DB_USERS . ") OR id IN (SELECT id FROM " . DB_PAGES . ") OR id IN (SELECT id FROM " . DB_GROUPS . " WHERE group_privacy IN ('open','closed')))
        AND type IN ('user','page','group') AND active=1
        ORDER BY name ASC
        LIMIT $fromRow,$limit");

我的表格结构enter image description here

这是我的查询,我可以检索1个值。请帮忙。谢谢

1 个答案:

答案 0 :(得分:-1)

您可以使用下标方法,如:

如果您的对象为$query,请使用$query['some_sub_field']

试试这个。