1
votes

Iam using codeigniter for developing a website.I tried to join multiple tables and got the following error.

A Database Error Occurred 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 ') ORDER BY table1.value ASC' at line 4

SELECT `table1`.* FROM `table1` LEFT JOIN `table2` ON `table2`.`id`=`table1`.`id` WHERE `table1`.`p_id` IN() ORDER BY `table1`.`value` ASC

Filename: C:/xampp/htdocs/limca/system/database/DB_driver.php

Line Number: 691

How to solve this error?

3

3 Answers

4
votes

Add some values inside WHERE IN(?)

SELECT `table1`.* FROM `table1` 
LEFT JOIN `table2` ON `table2`.`id`=`table1`.`id` 
WHERE `table1`.`p_id` IN(?) ORDER BY `table1`.`value` ASC 
2
votes

You have to pass comma separated ids in where table1.p_id in(1,2,3) clause

2
votes

IN() can't be empty you need pass the values.

`table1`.`p_id` IN('id1','id2')