php - How do i add some data to a mysql resultset? -


as first comment suggested, i'm gonna try simplify question:

i got table:

  `id` int not null auto_increment primary key ,   `name` varchar( 60 ) not null ,   `address` varchar( 80 ) not null ,   `coords` spatial not null ,   `qual` int(3) not null; 

i got data:

pan africa market, seattle, 47.608941 -122.340145,-65 buddha thai & bar, seattle, 47.613591 -122.344394,-30 melting pot, seattle, 47.624562 -122.356442,-75 ipanema grill, seattle, 47.606366 -122.337656,-90 sake house, seattle, 47.612820 -122.34567,-69 crab pot, seattle, 47.605961 -122.34036,-70 mama mexican kitchen, seattle, 47.613975 -122.345467,-44 wingdome, seattle, 47.617215 -122.326584,-57 piroshky piroshky, seattle, 47.610127 -122.342838,-100 

how make sql query mariadb or mysql selects fields , every data inside polygon , creates new column in resulset this:

<name="pan africa market" address="seattle" coords="47.608941 -122.340141" qual="-65" icon="3"/> 

with conditions:

if qual>-10 new column = 0, if -10>qual>-30 icon = 1, if -30>qual>-50 icon = 2, if -50>qual>-70 icon = 3, if -70>qual>-90 icon = 4, if -90>qual new icon = 5 

you can use case statment this. believe following statement should column you're looking (you can append between select , rest of columns specify in resultset).

select (case when (`qual` > -10) 0 when (`qual` < -10 && `qual` > -30) 1 when (`qual` < -30 && `qual` > -50) 2 when (`qual` < -50 && `qual` > -70) 3 when (`qual` < -70 && `qual` > -90) 4 when (`qual` < -90) 5 end) icon tablename 

apologies if syntax isn't quite right since spend of time in t-sql, should work. here's resource case if need tweak bit: mysql: case


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -