gpt4 book ai didi

php - sql INNER JOIN 中的位置不起作用?

转载 作者:行者123 更新时间:2023-11-29 09:03:32 25 4
gpt4 key购买 nike

我想要使用 $find 选择 WHERE 数据,但它(WHERE)在以下查询中不起作用,并且我的输出是 There is not,如何修复它?

$find="hello";
$query = $this->db->query('
SELECT tour_foreign.name,
tour_foreign_residence.name_re,
tour_foreign_airline.name_airline,
tour_foreign.service,
tour_foreign.date_go,
tour_foreign.date_back,
tour_foreign.term
FROM tour_foreign
INNER JOIN tour_foreign_residence
ON ( tour_foreign.id = tour_foreign_residence.relation )
INNER JOIN tour_foreign_airline
ON ( tour_foreign.id = tour_foreign_airline.relation )
WHERE tour_foreign.name LIKE "%' . $find . '%"
OR tour_foreign_residence.name_re LIKE "%' . $find . '%"


');

if ($query->num_rows() > 0) {
foreach ($query->result() as $val) {
echo $val->name . '<br>';
}
} else {
echo 'There is not';
}

最佳答案

WHERE 之前(在tour_foreign_airline.relation之后)有一个额外的逗号。

编辑:我看到您现在已修复它,但 JOIN 看起来仍然错误。试试这个:

INNER JOIN tour_foreign_residence
ON (tour_foreign.id = tour_foreign_residence.relation)
INNER JOIN tour_foreign_airline
ON (tour_foreign.id = tour_foreign_airline.relation)

关于php - sql INNER JOIN 中的位置不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7810662/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com