gpt4 book ai didi

php - 在接下来的第 4 列中查找 CI 数据库错误

转载 作者:搜寻专家 更新时间:2023-10-30 23:37:46 24 4
gpt4 key购买 nike

我有这个错误:

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'condition LIKE '%Chisel Round size: 120x3/440%')' at line 3

SELECT * FROM `inv_tool` WHERE (insert_date LIKE '%Chisel Round size: 120x3/440%' 
|| item_group LIKE '%Chisel Round size: 120x3/440%' ||
item_name LIKE '%Chisel Round size: 120x3/440%' ||
serial_number LIKE '%Chisel Round size: 120x3/440%' ||
condition LIKE '%Chisel Round size: 120x3/440%')

Filename: D:/LocalWebServer/htdocs/ptes_is/application/models/Model_invsys.php

Line Number: 73

如果我使用超过 3 列来查找:

       public function find_in_tool ($find) {
$this -> db -> where ("(insert_date LIKE '%$find%' ||
item_group LIKE '%$find%' || item_name LIKE '%$find%' ||
serial_number LIKE '%$find%' || condition LIKE '%$find%')");
$query = $this -> db -> get ('inv_tool') ;
return $query -> result () ;
}

但是如果我只用3个,是没有问题的。

       public function find_in_tool ($find) {
$this -> db -> where ("(insert_date LIKE '%$find%' ||
item_group LIKE '%$find%' || item_name
LIKE '%$find%')");
$query = $this -> db -> get ('inv_tool') ;
return $query -> result () ;
}

但我真的需要超过 3 ...

最佳答案

与列数无关,与MySQL/MariaDB保留关键字(条件)有关:https://dev.mysql.com/doc/refman/5.5/en/keywords.html

用反引号包裹您的列名和表名以避免冲突:

`condition` LIKE ...

关于php - 在接下来的第 4 列中查找 CI 数据库错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39503910/

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