mysql - Using +0 in order clause -


i have column "available" either returns "yes" or instance "30 min". sort table have found out works intended "yes" comes first, , "30 min" comes after.
order available + 0 asc
though works not know why have put +0 column. can elaborate?

edit: example on query
note clauses not here, , if(x null) return if there no result aka null value.

select distinct r.rname, if(b.stime null, 'yes', 'yes') available, r.mperson rooms r left outer join bookings b using (rname) union select b.rname, concat(minute(timediff(b.etime, '$sdate')), ' min') available,      r.mperson     bookings b inner join rooms r using(rname) order    available + 0 asc, rname asc 

you're implicitely converting available value number, can see trying

select "30 minutes" + 0; ==> returns 30 select "2 hours" + 0; ==> returns 2 select "yes" + 0; ==> returns 0 

this makes "yes" (or string not starting number) first returned value instead of last one.

this does change order feels hacky , less efficient using pure numeric field (which indexed).

more should define schema such have precise non polymorphic fields.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -