CodeIgniter Forums
problem with a query - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: problem with a query (/showthread.php?tid=20195)



problem with a query - El Forum - 07-01-2009

[eluser]lord_nerevar[/eluser]
Hi all, i'm a newbie of CI =)

I'm creating a controller that creates a temp table and populate it whit the result of a query.
my query looks like this:

CREATE TABLE match SELECT .. FROM ... WHERE ..

if i write the query directly in phpMyAdmin, the query will work perfectly, but if i insert the query in the controller, it doesn't work.

$sql = "CREATE TABLE match SELECT * FROM oggetti"; //this query is an example
$this->db->query($sql);

i receive this error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'match SELECT * FROM oggetti' at line 1

CREATE TABLE match SELECT * FROM oggetti