我有一组连接表,我正在通过以下方式查询:
$query = $this->mysqli->query("
SELECT DISTINCT name, website, email
FROM sfe
INNER JOIN ef ON sfe.ID_SFE = ef.ID_SFE
INNER JOIN f ON f.ID_F = ef.ID_F
INNER JOIN ad ON ad.ID_SFE = ef.ID_SFE
WHERE name LIKE '%{$sanitized}%' OR
website LIKE '%{$sanitized}%' OR
business_name LIKE '%{$sanitized}%' OR
email LIKE '%{$sanitized}%'
");
其中ID_SFE
是表的主键,sfe
也是表的外键ef
。
当我进行此查询时,我会使用以下内容回显结果列表:
while ($result = $query->fetch_object()) {
$query_result = $result->"name";
echo "$query_result"
}
因为现在我还想ID_SFE
在同一个while循环中找到值,所以我尝试将ID_SFE
名称、网站、电子邮件一起添加到SELECT DISTINCT列表中,但是,我得到了ERROR: There was a problem with the query.
如何获取的值ID_SFE
并将其存储到 while 循环内的另一个变量中?
谢谢