我有这个错误:
错误号码:1064
您的SQL语法有错误;检查手册 对应于您的MariaDB服务器版本,以获得正确的语法 接近'条件喜欢'%凿子圆形尺寸: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 /htdocs/ptes_is/application/models/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 () ;
}
但我真的需要3个以上......
答案 0 :(得分:1)
与列数无关,与MySQL / MariaDB保留关键字有关(条件):https://dev.mysql.com/doc/refman/5.5/en/keywords.html
在反引号中包装列名和表名以避免冲突:
`condition` LIKE ...