CodeIgniter Forums
db select syntax - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: db select syntax (/showthread.php?tid=26706)



db select syntax - El Forum - 01-21-2010

[eluser]jakeone[/eluser]
I'm trying to extract the first 200 characters from a larger field in MySQL (v 5.1.36) The raw SQL works:
Code:
SELECT LEFT( detail, 200 )FROM bids AS summary
. But when I try this:

Code:
$this->db->select("bids.bidID, bids.detail, LEFT(bids.detail, 200) AS summary");

I get a "database error. Error No. 1064" message as follows:

Code:
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 'AS summary...

Any ideas?


db select syntax - El Forum - 01-21-2010

[eluser]flaky[/eluser]
Code:
$this->db->select("bids.bidID, bids.detail, LEFT(bids.detail, 200)");
$this->db->from('bids AS summary');
$this->db->get();