一、 SELECT * INTO T1 FROM T2 这种语法在mysql中会报错,用下面的语法代替即可
A> 当新表不存在,需要新建时:
CREATE TABLE rice_test
(SELECT 商品名称, 商品链接 FROM rice_june
WHERE `平台` = '苏宁');
A> 当新表已经存在,且需要全字段插入时(新表与源表的字段要完全一致):
INSERT INTO `beer-new-june`
SELECT * from `beer-missed`;
A> 当新表已经存在,只需要插入指定的某几列的数据时:
INSERT INTO `beer-new-june` (field1, field2, field3,...,field9)
SELECT field1, field2, field3,...,field9 from `beer-missed`;
二、 mysql多表连接查询时,要去掉重复列,可以用USING()效果等同ON T1.ID = T2.ID
SELECT *
FROM total AS t1 LEFT JOIN (
SELECT DISTINCT 商品链接, 商品主图片链接 AS 商品主图
FROM rice_june) AS t2 USING(商品链接);
三个表连接的时候如下:
select * from (select * from school left join course USING (courseid)) e left join student USING (studentid);