删除重复数据
DELETE t1 FROM invest_year t1, invest_year t2 WHERE t1.pro_id = t2.pro_id AND t1.pro_year = t2.pro_year AND t1.id > t2.id;
自关联,保留id最小的那一条,其它的都删除
DELETE t1 FROM invest_year t1, invest_year t2 WHERE t1.pro_id = t2.pro_id AND t1.pro_year = t2.pro_year AND t1.id > t2.id;
自关联,保留id最小的那一条,其它的都删除
SELECT product_brand FROM shop_product WHERE LENGTH(product_brand)>...
是由表格字段ID的数据库类型造成的,smallint最大数值就是65535,修改成int就可以了...
select count(id),字段from 表名 group by字段 having count(字段)>1;...
减去一天SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY);减去一个小时hour(now())-1...
in 或者out 参数 :需要设定长度,否则保存的时候会报错;参数和字段名重名的时候,为了区别字段名,需要在字段前面加入表名创建临时表CREATE TEMPORARY TABLE&...
if the end if 最后需要用分号';'结束out的值在select 中需要用 into赋值 其他情况 可以尝试setphp获取out的值需要$sql="call&n...