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;