我有这个错误:
错误编号:1064
你的SQL语法有错误;查看手册对应于您的MariaDB服务器版本以使用正确的语法近'condition LIKE '%Chisel圆形尺寸:120x3/440%')'在第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%')
文件名:D:/ LocalWebServer /根/ptes_is/应用程序/模型/Model_invsys.php
行号: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 () ;
}
与列数无关,与MySQL/MariaDB保留关键字(条件)有关:https://dev.mysql.com/doc/refman/5.5/en/keywords.html
将列名和表名用反引号括起来以避免冲突:
`condition` LIKE ...