字符串数组是否包含入参
- 数据库中存储的是一个字符串数组,传入一个字符串数组或一个字符串,判断数据库中存储的数组是否包含传入的元素。
-
queryWrapper.apply(入参!=null,"FIND_IN_SET('"+入参+"',字段名)");
对象数组中剥离一列数据,形成一个新的List
List<Integer> userIds = userList.stream().map(User::getId).collect(Collectors.toList());
多条件查询
- 使用or连接,可以用1=0拼接。
- 使用and连接,可以用1=1拼接。
SELECT * FROM `sys_image`,sys_tower,sys_device where sys_device.id = sys_image.device_id and sys_tower.id=sys_device.tid and sys_image.create_date<='2022-03-14 16:20:34' and sys_image.create_date>='2022-03-14 16:00:34' and ( 1=0 or device_id = 41 or sys_tower.`name` = 'GD6' or 1=0)