普通车辆入园统计结果数量和普通车辆统计列表数量不一致?
列子:数量:967,列表:974
对比统计数量和统计列表的统计方法
一:查询出车辆滞留表数据List
二:查询出系统登记车辆数据List
三:比较两个List
四:equals()相同车牌号计数统计
关联两个表,条件车牌号相同 =
同:车辆滞留表数据List和登记车辆数据查出数据条数相同;
异:比较车牌号数据不同
统计数量:
//普通车辆数量
int ordinaryVehicleGardenCount = 0;
//遍历普通车辆数据
for (DspMjzkOrdinaryVehicle car : value) {
//遍历滞留表数据
for (DspIccEventCarRetention iccEventCarRetention : iccEventCarRetentions) {
//如果普通车辆和滞留表的车牌号对应,那么加1
if (car.getVehiclesId().equals(iccEventCarRetention.getCarNum())) {
ordinaryVehicleGardenCount++;
}
}
}
统计列表:
SELECT
b.vehicles_id,
a.car_num
FROM dsp_icc_event_car_retention a,
dsp_mjzk_ordinary_vehicle b
WHERE a.car_num = b.vehicles_id
AND a.is_deleted = 0
AND a.`status` = 1
AND b.vehicle_use = 1
AND b.is_deleted = 0
AND b.`status` = 1
AND b.create_dept IS NOT NULL
AND a.car_num IS NOT NULL;
1.对于字符串的 equals
方法:
equals
是区分大小写的,即大写和小写字母被视为不同。equalsIgnoreCase
方法。2.在 MySQL 中,字符串的比较默认是不区分大小写的。
SELECT *
FROM dsp_mjzk_ordinary_vehicle
WHERE vehicles_id='川fjW790'
?
BINARY
操作符-- BINARY 字段 实现二进制的比较 在mybatisplus中xxx.xml会报错
-- BINARY 操作符在 MyBatis Plus 的查询构造器中可能不被支持
SELECT *
FROM dsp_mjzk_ordinary_vehicle
WHERE BINARY vehicles_id ='川FJW790';
?换为'川fjW790'查不出来数据
COLLATE
子句utf8mb4_bin
是指定二进制比较的字符集
-- 字段COLLATE utf8mb4_bin实现进行二进制比较
SELECT *
FROM dsp_mjzk_ordinary_vehicle
WHERE vehicles_id COLLATE utf8mb4_bin='川FJW790'
换为'川fjW790'查不出来数据
1.测试发现BINARY
操作符在 MyBatis Plus 的查询构造器中可能不被支持
2.最终使用COLLATE
子句
SELECT
b.vehicles_id,
a.car_num
FROM dsp_icc_event_car_retention a,
dsp_mjzk_ordinary_vehicle b
WHERE a.car_num COLLATE utf8mb4_bin = b.vehicles_id COLLATE utf8mb4_bin
AND a.is_deleted = 0
AND a.`status` = 1
AND b.vehicle_use = 1
AND b.is_deleted = 0
AND b.`status` = 1
AND b.create_dept IS NOT NULL
AND a.car_num IS NOT NULL;