Search code examples
phpmysqlcodeignitersubqueryexists

CodeIgniter query builder syntax for WHERE EXISTS (subquery)


I'm trying to do a subquery with

$this->db->where(" EXISTS (SELECT * FROM myTable)");

But it doesnt work, the output of this is: myquery + WHERE 'EXISTS (SELECT * FROM myTable);

That quote before the EXISTS makes the query unresolvable!

Does anyone knows how to solve it?


Solution

  • please remove space before and after EXISTS keyword.that does not display any error.

    $this->db->where("EXISTS(SELECT * FROM myTable)");