开发者

codeigniter sql

开发者 https://www.devze.com 2023-03-05 19:32 出处:网络
can someone please help me to convert this mysql query to convert it to CodeIgniter SQL method $sql = \"SELECT MAX( SUBSTRING( locationID , 3, 11 ) )

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

0

精彩评论

暂无评论...
验证码 换一张
取 消