关于2个表合并的问题 本帖最后由 lyyailxj13 于 2013-01-26 23:00:02 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 insert into A(用户id,用户名,密码)select 用户id,用户名,密码from Bwhere not exists(select 1 from A where B.用户id =A.用户id and A.用户名=B.用户名 ) 请问一下 select 1 from A 这个”1“ 是??请原谅我是新手 这里exists只是去查询满足条件的记录 如果你select column(表中的列名)、select * 都可以但是select 1 查出来的记录都是常数1 在效率上讲1> column > * insert into Aselect B_id,B_name,B_mi from Bwhere not exists(select A_name from A where A_name=B_name )可以实现两个表合并,但不知道如何把发现重复的用户id加一位 insert into A(用户id,用户名,密码)select 用户id,用户名,密码from Bwhere not exists(select 1 from A where B.用户id =A.用户id and A.用户名=B.用户名 ) insert into A(用户id,用户名,密码)select MAX(A.用户id)+1,B.用户名,B.密码from A,Bwhere not exists(select 1 from A where A.用户名=B.用户名 ) 楼主 SQL 语法有点差,请参考这个资料吧:http://www.w3school.com.cn 呵呵,数据库书上讲的几个概念看不懂。请讲的简单好懂一点。 触发器 能否按创建时间批量删除表? java调用存储过程 sql数据库从本地上传到远程电脑 小女子遇到问题:SQL语句只调用一次,却重复执行多次! 知道一年中的第几周,怎么知道该周的起始日期和结束日期 MYSQL不能远程应用 请问哪里有 oracle for linux 客户端 下载?谢谢! 紧急求救!!!!!! 求教各位基友一个问题!!!急 高分,怎么在sql2008理设置登录账号
select 用户id,用户名,密码
from B
where not exists(select 1 from A where B.用户id =A.用户id and A.用户名=B.用户名 )
请问一下 select 1 from A 这个”1“ 是??
请原谅我是新手
这里exists只是去查询满足条件的记录 如果你select column(表中的列名)、select * 都可以但是select 1 查出来的记录都是常数1 在效率上讲1> column > *
select B_id,B_name,B_mi from B
where not exists(select A_name from A where A_name=B_name )
可以实现两个表合并,但不知道如何把发现重复的用户id加一位
select 用户id,用户名,密码
from B
where not exists(select 1 from A where B.用户id =A.用户id and A.用户名=B.用户名 )
select MAX(A.用户id)+1,B.用户名,B.密码
from A,B
where not exists(select 1 from A where A.用户名=B.用户名 )
http://www.w3school.com.cn