将一个表复制到其他表,避免某些记录 [英] Copy one table to other table avoiding certain records

查看:77
本文介绍了将一个表复制到其他表,避免某些记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在尝试将一个表(t1)的记录复制到其他表(t2)。两者都有相同的字段,但我必须在复制到t2时排除某些记录。

这里是我的查询但它不起作用,当我搜索时我仍然能够看到记录



查询 -



INSERT INTO t2

SELECT * FROM t1

不存在(从t1中选择*(t1.Bus_name喜欢'009%'; t1.Bus_name喜欢'01%';));



我仍然在新表t2中看到商家名称以009和01开头的记录。



请帮助!!

解决方案

简化你的SQL:



  INSERT   INTO  t2 
SELECT *
FROM t1
WHERE t1.Bus_name NOT LIKE ' 009%' AND t1.Bus_name LIKE ' 01%


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 !!

解决方案

Simplify your SQL to this:

INSERT INTO t2
SELECT *
FROM t1
WHERE t1.Bus_name NOT LIKE '009%' AND t1.Bus_name NOT LIKE '01%'


这篇关于将一个表复制到其他表,避免某些记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆