相当于内连接:
{ DELETE t1 FROM tdb_goods AS t1, (SELECT goods_id, goods_name FROM tdb_goods
GROUP BY goods_name HAVING COUNT(goods_name)>1) AS t2
WHERE t1.goods_name = t2.goods_name AND t1.goods_id>t2.goods_id; }
看不懂的同学可以看:http://database.51cto.com/art/201009/225564.htm
{ DELETE t1 FROM tdb_goods AS t1, (SELECT goods_id, goods_name FROM tdb_goods
GROUP BY goods_name HAVING COUNT(goods_name)>1) AS t2
WHERE t1.goods_name = t2.goods_name AND t1.goods_id>t2.goods_id; }
看不懂的同学可以看:http://database.51cto.com/art/201009/225564.htm
有个疑问,oracle中如果select 列表中没有出现在组函数中,都应该在group by 中,mysql 为啥没报错,老师刚才group by 就写了一个字段?
2017-08-15
mysql> DELIMITER //
mysql> CREATE PROCEDURE removeUserById(IN id INT UNSIGNED)
-> BEGIN
-> DELETE u FROM users AS u WHERE u.id=id;
-> END
-> //
给users一个别名也是可以的啊,没关系
mysql> CREATE PROCEDURE removeUserById(IN id INT UNSIGNED)
-> BEGIN
-> DELETE u FROM users AS u WHERE u.id=id;
-> END
-> //
给users一个别名也是可以的啊,没关系
2017-08-15
哈哈哈哈 这老师教的不错,谁都不可能不犯错,这种不是技术上的错误就更不用被拿来吐槽了,更何况还是在控制台上面写
2017-08-14