试试,调试一下: SELECT username,password FROM table1 UNION SELECT DISTINCT t1.username,t1password,t2.username,t2.password FROM table1 t1, table2 t2 WHERE t1.username= t2.username AND t1.password =t2.password
insert into tbname1 select * from tbname2;select * from ( select * from tbname1 union select * from tbname2) t where t.col=......;
再具体点:就是根据username选出password 请给出相应的例子。谢谢
create table table3 as select username,password from table1 union select username,password from table2 ;drop table1; drop table2;rename table3 to table1;
select * from (select username,passwordfrom tbl_1 union select username,password from tbl_2) a where a.username = 'aaa'
SELECT A.*,B.* FROM table1 A,table2 B WHERE A.username='xxxx' or b.username='xxxx' ;
create view v_tab as select username,passwordfrom tbl_1 union select username,password from tbl_2;select * from v_tab where ... 如果2个表中记录没有重复的,可以将union换成union all,能加快速度。
SELECT username,password
FROM table1
UNION
SELECT DISTINCT t1.username,t1password,t2.username,t2.password
FROM table1 t1, table2 t2
WHERE t1.username= t2.username AND
t1.password =t2.password
select * from tbname1
union
select * from tbname2) t
where t.col=......;
请给出相应的例子。谢谢
select username,password from table1
union
select username,password from table2 ;drop table1;
drop table2;rename table3 to table1;
from
(select username,passwordfrom tbl_1
union
select username,password from tbl_2) a
where a.username = 'aaa'
WHERE A.username='xxxx' or b.username='xxxx' ;
as
select username,passwordfrom tbl_1
union
select username,password from tbl_2;select * from v_tab where ...
如果2个表中记录没有重复的,可以将union换成union all,能加快速度。