php - Want to order by cast but after value -
i'm using ajax fetch more photos gallery based on views. gallery has set of 10 photos showing. want next 10 photos in order based on view count high low.
$last_image_view_count = 232; "select * `gallery` order cast(`views`<'$last_image_view_count' signed) desc limit 10"; the code above works...but not in order (230 - 216 - 205 etc). scattered under 232. need figuring out how in order high low.
"select * `gallery` `views` < '$last_image_view_count' order `views` desc limit 10"; use where-statement select desired set of data (from understand want those, view-count that's less $last_image_view_count).
you can order views column.
there's no need cast in order by-statement. code ordering 1 or 0 (1 if views less variable, otherwise 0).
Comments
Post a Comment