how to make query with substr in eloquent (laravel 4)? -


i have query:

select substr(id,1,4) id meteo.a2012 group substr(id,1,4) 

i want take first 4 numbers id row, i'm trying in eloquent, how do?

thanks.

you need use raw expressions can use special functions that.

model::select(db::raw('substr(id, 1, 4) id'))->groupby(db::raw('substr(id, 1, 4)'))->get(); 

where model eloquent model want run query on.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Socket.connect doesn't throw exception in Android -

SPSS keyboard combination alters encoding -