sql怎么改能去掉隐式转换的问题: SELECT a.TASK_ID, a.TASK_NAME, a.CHANNAL_ORG_ID, a.CHANNAL_ORG_NAME, a.POLICY_ID, a.POLICY_NAME, a.MAITAIN_ID, a.MAITAIN_NAME, a.FROM_TEMPLATE, a.is_batches, a.BATCH_ID, a.CUST_LIST_ID, a.IS_REASSIGNMENT, a.DISPATCH_TYPE, a.TWICE_VERIFY, a.EVENT_ID, a.BUSINESS_SCENE, a.TEMP_ID FROM crm_task_info as a left join crm_task_info_ext as b on a.TASK_ID = b.TASK_ID WHERE is_marketing = 1 and b.IS_VIP = '1' AND PRO_ID = 97 AND (START_TIME < '2023-05-30 00:00:00'AND END_TIME >'2023-05-30 00:00:00')
时间: 2024-02-14 21:05:42 浏览: 82
您可以将查询条件中的字段类型与数据库表中字段类型保持一致,避免出现隐式转换的问题。如果表中字段类型为 long 类型,则查询条件中的 PRO_ID 也应该为 long 类型,而不是字符串类型。修改后的 SQL 语句如下:
```
SELECT
a.TASK_ID,
a.TASK_NAME,
a.CHANNAL_ORG_ID,
a.CHANNAL_ORG_NAME,
a.POLICY_ID,
a.POLICY_NAME,
a.MAITAIN_ID,
a.MAITAIN_NAME,
a.FROM_TEMPLATE,
a.is_batches,
a.BATCH_ID,
a.CUST_LIST_ID,
a.IS_REASSIGNMENT,
a.DISPATCH_TYPE,
a.TWICE_VERIFY,
a.EVENT_ID,
a.BUSINESS_SCENE,
a.TEMP_ID
FROM
crm_task_info as a
left join crm_task_info_ext as b on a.TASK_ID = b.TASK_ID
WHERE
is_marketing = 1
and b.IS_VIP = '1'
AND PRO_ID = 97L
AND (START_TIME < '2023-05-30 00:00:00' AND END_TIME > '2023-05-30 00:00:00')
```
请注意,以上示例中,我将查询条件中的 "PRO_ID = 97" 改为了 "PRO_ID = 97L",即指定了 long 类型的值。这样可以避免隐式转换和索引失效等问题。
阅读全文