Error executing request in Codeigniter

I use codeigniter to develop a site. I tried to join multiple tables and got the following error.

Database Error Occurred Error Number: 1064

You have an error in the SQL syntax; check the manual corresponding to the MariaDB server version for the correct syntax to use next to it) ORDER BY table1. valueASC 'on line 4

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

File Name: C: /xampp/htdocs/limca/system/database/DB_driver.php

Line Number: 691

How to solve this error?

+4
source share
3 answers

Add 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 
+4
source

You must pass the identifiers separated by commas to the where table1.p_id in(1,2,3)sentence

+2
source

IN() cannot be empty, you need to pass values.

`table1`.`p_id` IN('id1','id2')
+2
source

Source: https://habr.com/ru/post/1694511/