sql INNER JOIN 中的位置不起作用?
我想要使用 $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';
}
I want WHERE data select with $find, but it(WHERE) not work in following query and my output is There is not
, how fix it?
$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';
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在
WHERE
之前(在tour_foreign_airline.relation之后)有一个额外的逗号。编辑:我看到您现在已修复它,但
JOIN
看起来仍然错误。试试这个:You have an extra comma before the
WHERE
(after tour_foreign_airline.relation).Edit: I see you fixed it now, but the
JOIN
still looks wrong. Try this: