SQL 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: SQL query (/showthread.php?tid=42577) |
SQL query - El Forum - 06-11-2011 [eluser]Unknown[/eluser] I want to do this sql query select table1.name, table1.address from table1 where table1.name = table2.name and table2.id = '12345'; I tried in my models with this syntax $this->db->query("select........."); but the result is error like this... A Database Error Occurred Error Number: 1064 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 where table1.name = table2.name... Anybody please help me... to do that sql query (.. for my final assigment this semester... I'm gonna die ( SQL query - El Forum - 06-11-2011 [eluser]web-johnny[/eluser] [quote author="Nadia Orin" date="1307802040"]I want to do this sql query select table1.name, table1.address from table1 where table1.name = table2.name and table2.id = '12345'; I tried in my models with this syntax $this->db->query("select........."); but the result is error like this... A Database Error Occurred Error Number: 1064 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 where table1.name = table2.name... Anybody please help me... to do that sql query (.. for my final assigment this semester... I'm gonna die ([/quote] Your query is wrong that's why . There is no such a table2!!!! perhaps you want to do a join. Read the active record it's quite easy. SQL query - El Forum - 06-11-2011 [eluser]Unknown[/eluser] aha.... thanks thanks thanks... I've been "panic at the disco".. :cheese: .... aaaaa thanks a lot... :cheese: I'm still newbiew :red: thanks thanks thanks ;D |