IF EXISTS ( SELECT COUNT( 1 ) AS count FROM ( SELECT t822.order_plan_id, overview.order_plan_id AS ovid, overview.hr_request_number, overview.hr_request_title, overview.response_deadline, overview.hr_request_create_office_group_code, overview.update_datetime FROM t_hr_request_overview overview LEFT JOIN tb_0080022_dt_pc_order_management t822 ON overview.order_plan_id = t822.order_plan_id WHERE t822.order_plan_id = "#000000639201" ) select_count )THEN SELECT TRUE AS result; ELSE SELECT FALSE AS result END IF 修改成正确代码
时间: 2023-08-18 07:04:25 浏览: 113
tree-log.rar_The Just_log
根据您提供的代码,以下是修改后的正确代码:
```sql
DECLARE @count INT;
SELECT @count = COUNT(*)
FROM (
SELECT
t822.order_plan_id,
overview.order_plan_id AS ovid,
overview.hr_request_number,
overview.hr_request_title,
overview.response_deadline,
overview.hr_request_create_office_group_code,
overview.update_datetime
FROM
t_hr_request_overview overview
LEFT JOIN tb_0080022_dt_pc_order_management t822 ON overview.order_plan_id = t822.order_plan_id
WHERE
t822.order_plan_id = '#000000639201'
) AS select_count;
IF @count > 0 THEN
SELECT 'true' AS result;
ELSE
SELECT 'false' AS result;
END IF;
```
在上述代码中,我们使用变量 `@count` 来存储查询结果的行数,并通过 IF-ELSE 语句来判断是否为空。如果 `@count` 大于 0,则返回 true;否则,返回 false。
请注意,具体的实现方式可能根据您所使用的数据库类型和编程语言有所不同。您需要将其适配到您所使用的数据库和编程环境中。
阅读全文