i am facing problems while specifying where condition in select statement for uninon of my three tables. Here is my code
create table master_data(
select id,number,product_id
from tablename_A
where id REGEXP '^[0-9]*$' and id != ' ' and product_id != 0 and product_id is not null
union
select id,number,product_id
from tablename_B
where id REGEXP '^[0-9]*$' and id != ' ' and product_id != 0 and product_id is not null
union
select id,number,product_id
from tablename_C
where id REGEXP '^[0-9]*$' and id != ' ' and product_id != 0 and product_id is not null
);
i am getting this error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'id != ' ' and product_id != 0 and product_id is not nullunionselect id' at line 8