MySQL: The used SELECT statements error -


can explain why have error in sql statement?

(select group_concat(concat(column_name))     information_schema.columns     table_name = '<table name>'     , table_schema = '<dbname>'     order ordinal_position)  union (select * hars_return outfile "e:\\test.csv" fields terminated "," lines terminated "\n"); 

am got query right?

the error got running query is:

error code 1222: used select statements have different number of columns

when use union or union all, each subquery has have same number of columns.

your first query returning 1 column. second returning column table. hence, getting column count error (unless table happens have 1 column).

also, concat() in concat(column_name) totally unnecessary.


Comments