概述
Mysql
--重复sn始终取最后一条
select * FROM production_log WHERE ( sn in('1') or imei1 in('1') or imei2 in('1') ) and dt IN (
select * from (
(SELECT max(dt) FROM production_log WHERE ( sn in('1') or imei1 in('1') or imei2 in('1') ) GROUP BY sn )
b)
) order by sn
--删除地址重复,保留最小id
DELETE FROM file WHERE fileaddress IN (
select * from (
( SELECT fileaddress FROM file GROUP BY fileaddress HAVING count(fileaddress) > 1)
a)
)
AND id NOT IN (
select * from (
(SELECT min(id) FROM file GROUP BY fileaddress HAVING count(fileaddress) > 1 )
b)
)
找出fileaddress重复的地址
找出fileaddress重复的地址 且不删除最小id
#看看还有没有重复的
select * from production_log where dt>'2022-07-25' group by sn having (count(sn)>1)
Mysql实现导入生产数据
想用sql脚本直接导入,发现低版本5.5.38对事务仅支持sql语句 使while for支持不好。
还是用C#吧。
//生成imei校验位
public static char GetIMEICheckDigit(string imei)
{
int i;
int sum1 = 0, sum2 = 0, total = 0;
int temp = 0;
for (i = 0; i < 14; i++)
{
if ((i % 2) == 0)
{
sum1 = sum1 + imei[i] - '0';
}
else
{
temp = (imei[i] - '0') * 2;
if (temp < 10)
{
sum2 = sum2 + temp;
}
else
{
sum2 = sum2 + 1 + temp - 10;
}
}
}
total = sum1 + sum2;
if ((total % 10) == 0)
{
return '0';
}
else
{
return (char)(((total / 10) * 10) + 10 - total + '0');
}
}
最后
以上就是阳光烤鸡为你收集整理的每日的盐 C#生成imei校验位的全部内容,希望文章能够帮你解决每日的盐 C#生成imei校验位所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复