mysql query to avoid multiple queries -


i have table :

create table my_table (   col1 varchar(55),   col2 varchar(55),   col3 varchar(55),   0101 varchar(55),   0202 varchar(55),   0303 varchar(55) ); 

now want fill table data returned query, 1 example :

 select   col1, col2, col3, group_concat(col4)      my_other_table  group col1, col2, col3 

now query results in line (and more case 1 line enough) :

 col1     col2        col3      group_concat(col4)  -------------------------------------------------  fib100   internet   1megamax       0202,0404 

now want check if in concatenated values have column name of not yet populated columns (0101 0202 0303) of table my_table. if true want put x

like :

table : my_table after insertion

 col1     col2        col3       0101   0202    0303   -----------------------------------------------------  fib100   internet   1megamax             x 

my question : there way same query ??

thank

hope you.

i've changed names of columns (you can't use numbers column's name)

create table my_table1 (   col1 varchar(55),   col2 varchar(55),   col3 varchar(55),   c0101 varchar(55),   c0202 varchar(55),   c0303 varchar(55) );  create table my_other_table (   col1 varchar(55),   col2 varchar(55),   col3 varchar(55),   col4 varchar(55) ); 

then, query is:

insert my_table (col1,col2,col3,c0101,c0202,c0303)     select col1, col2, col3,             if (group_concat(col4) '%0101%' , 'x' , '') c0101,            if (group_concat(col4) '%0202%' , 'x' , '') c0202,            if (group_concat(col4) '%0303%' , 'x' , '') c0303     my_other_table     group col1, col2, col3; 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -