我正在尝试在所有表和列中搜索某个值,并且我正在使用 php 连接到 IBM DB2 数据库。我想知道该错误是否是由于多次使用联合引起的。
这是我的错误信息:
Improper use of a string column, host variable, constant, or function "NAMABARANG". SQLSTATE=42907 SQLCODE=-134
这是我的代码:
$keyword=$_GET['keyword'];
$query="SELECT * FROM INVENTORY WHERE NAMABARANG LIKE '%".$keyword."%'".
" UNION ALL SELECT * FROM INVENTORY WHERE ARRIVALDATE LIKE '%".$keyword."%'".
" UNION ALL SELECT * FROM INVENTORY WHERE PAPERNUMBER LIKE '%".$keyword."%'".
" UNION ALL SELECT * FROM INVENTORY WHERE SERIALNUMBER LIKE '%".$keyword."%'".
" UNION SELECT * FROM INVENTORY WHERE CONDITION LIKE '%".$keyword."%'".
" UNION ALL SELECT * FROM INVENTORY WHERE LOCATION LIKE '%".$keyword."%'".
" UNION ALL SELECT * FROM INVENTORY WHERE CONFIRMATIONDATE LIKE '%".$keyword."%'".
" UNION ALL SELECT * FROM INVENTORY WHERE BARCODE LIKE '%".$keyword."%'".
" UNION ALL SELECT * FROM USERANDPASSWORD WHERE USERNAME LIKE '%".$keyword."%'";
" UNION ALL SELECT * FROM USERANDPASSWORD WHERE ACCESS LIKE '%".$keyword."%'";