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

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -