codeigniter sql
can someone please help me to convert this mysql query to convert it to CodeIgniter SQL method
$sql = "SELECT MAX( SUBSTRING( locationID , 3, 11 ) )
FROM items WHERE LEFT( locationID , 2 ) = = ? "
Having values such as location id's such as AK23, LI343, JE343 etc.. it returns the highest integer matching the prefix(JE, LI - given 2 character prefix in the where clause)
It will be great if you can please help me with this as the normal way of wriring sql in the mod开发者_如何学Goel does not work..
Thanks alot
db->query('SELECT MAX( SUBSTRING( locationID , 3, 11 ) ) FROM items WHERE LEFT( locationID , 2 ) = ?', array(args)
db->select('MAX(SUBSTRING( locationID , 3, 11))')->from('items')->where('LEFT( locationID , 2)', arg)->get()
hope that help
精彩评论