Mysql交集:
mysql不提供intersect求交集。
提供intersect的命令如下:
两个表的交集:(SELECT ColumnB FROM TableA WHERE ColumnA='Value1')INTERSECT (SELECT ColumnB FROM TableB WHERE ColumnA='Value2')
三个表的交集:(SELECT ColumnB FROM TableA WHERE ColumnA='Value1')INTERSECT (SELECT ColumnB FROM TableB WHERE ColumnA='Value2')INTERSECT (SELECT ColumnB FROM TableC WHERE ColumnA='Value3')
Mysql命令如下:
两个表的交集:
SELECT * FROM TableA AS TA, TableB AS TB WHERE TA.ColumnA='Value1' AND TB.ColumnA='Value2' AND TA.ColumnB=TB.ColumnB
三个表的交集
SELECT * FROM TableA AS TA, TableB AS TB,TableC AS TC WHERE TA.ColumnA='Value1' AND TB.ColumnA='Value2' AND TA.ColumnB=TB.ColumnB and TA.ColumnA=TC.CloumnB;
Mysql的清除表内容: truncate table
Mysql 查询数据导出到文件 select * from tableA into outfile 'c:\a.txt';
Mysql 复制表结构 select * into table_new from tableA;