Click here to Skip to main content
15,935,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am trying to copy records of one table(t1) to other table(t2). Both have same fields but I have to exclude certain records while copying to t2.
here is my query but it is not working and when i do search I am still able to see the records

Query -

INSERT INTO t2
SELECT * FROM t1
where not exists (select * from t1 where (t1.Bus_name like '009%'; and t1.Bus_name like '01%'; ));

I still see records with business name starting with 009 and 01 in my new table t2.

Please help !!
Posted

1 solution

Simplify your SQL to this:

SQL
INSERT INTO t2
SELECT *
FROM t1
WHERE t1.Bus_name NOT LIKE '009%' AND t1.Bus_name NOT LIKE '01%'
 
Share this answer
 
Comments
Member 12271876 27-Jan-16 16:35pm    
Thanks ! it worked..
ZurdoDev 28-Jan-16 7:06am    
You're welcome.
Member 12271876 28-Jan-16 10:16am    
Hi, Can u please look into this issue - http://www.codeproject.com/Questions/1075018/Can-I-Compare-Varchar-To-Float-In-Sql
If you have some time..? Thanks !

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900