如何在一个 mysql 字段中创建两个条件?
How do i create two conditions in one mysql field?
抱歉,我不知道如何表达这个问题,实际上它比听起来要复杂一点。我的数据库中有以下内容;请查看 link:
中的屏幕截图
我正在使用 BIRT 生成报告,我希望当优先级 = 2 时,它显示值 'High'。同样,当priority = 1时,它显示'Medium',当它= 1时,它显示'Low'.
但我也希望当 estimated_time = 4 时显示“16+hrs”,当 estimated_time = 3 时显示“< 16 小时”等等
现在我已经使用下面的代码设置了优先级;
SELECT date_created, CONCAT(first_name, " ", last_name) as user, e_name, cc_name, 'High' as priority, job_description, due_date, estimated_time, impediment
FROM job_planning as jp
INNER JOIN user as u
ON jp.user_id = u.id
INNER JOIN employer as e
ON jp.employer_id = e.id
INNER JOIN client_company as cc
ON jp.client_id = cc.id
WHERE jp.priority = '2'
union
SELECT date_created, CONCAT(first_name, " ", last_name) as user, e_name, cc_name, 'Medium' as priority, job_description, due_date, estimated_time, impediment
FROM job_planning as jp
INNER JOIN user as u
ON jp.user_id = u.id
INNER JOIN employer as e
ON jp.employer_id = e.id
INNER JOIN client_company as cc
ON jp.client_id = cc.id
WHERE jp.priority = '1'
union
SELECT date_created, CONCAT(first_name, " ", last_name) as user, e_name, cc_name, 'Low' as priority, job_description, due_date, estimated_time, impediment
FROM job_planning as jp
INNER JOIN user as u
ON jp.user_id = u.id
INNER JOIN employer as e
ON jp.employer_id = e.id
INNER JOIN client_company as cc
ON jp.client_id = cc.id
WHERE jp.priority = '0';
但是我怎样才能包含 estimated_time?我可以在 mysql 中使用 OR 吗?我不能使用 AND,因为那样会把两者分开。
感谢并感谢任何帮助。
SELECT ... ,
CASE priority WHEN 2 THEN 'High'
WHEN 1 THEN 'Medium',
ELSE 'Low'
END AS verbal_priority,
CASE estimated_time WHEN 4 THEN '16+hrs'
...
抱歉,我不知道如何表达这个问题,实际上它比听起来要复杂一点。我的数据库中有以下内容;请查看 link:
中的屏幕截图我正在使用 BIRT 生成报告,我希望当优先级 = 2 时,它显示值 'High'。同样,当priority = 1时,它显示'Medium',当它= 1时,它显示'Low'.
但我也希望当 estimated_time = 4 时显示“16+hrs”,当 estimated_time = 3 时显示“< 16 小时”等等
现在我已经使用下面的代码设置了优先级;
SELECT date_created, CONCAT(first_name, " ", last_name) as user, e_name, cc_name, 'High' as priority, job_description, due_date, estimated_time, impediment
FROM job_planning as jp
INNER JOIN user as u
ON jp.user_id = u.id
INNER JOIN employer as e
ON jp.employer_id = e.id
INNER JOIN client_company as cc
ON jp.client_id = cc.id
WHERE jp.priority = '2'
union
SELECT date_created, CONCAT(first_name, " ", last_name) as user, e_name, cc_name, 'Medium' as priority, job_description, due_date, estimated_time, impediment
FROM job_planning as jp
INNER JOIN user as u
ON jp.user_id = u.id
INNER JOIN employer as e
ON jp.employer_id = e.id
INNER JOIN client_company as cc
ON jp.client_id = cc.id
WHERE jp.priority = '1'
union
SELECT date_created, CONCAT(first_name, " ", last_name) as user, e_name, cc_name, 'Low' as priority, job_description, due_date, estimated_time, impediment
FROM job_planning as jp
INNER JOIN user as u
ON jp.user_id = u.id
INNER JOIN employer as e
ON jp.employer_id = e.id
INNER JOIN client_company as cc
ON jp.client_id = cc.id
WHERE jp.priority = '0';
但是我怎样才能包含 estimated_time?我可以在 mysql 中使用 OR 吗?我不能使用 AND,因为那样会把两者分开。
感谢并感谢任何帮助。
SELECT ... ,
CASE priority WHEN 2 THEN 'High'
WHEN 1 THEN 'Medium',
ELSE 'Low'
END AS verbal_priority,
CASE estimated_time WHEN 4 THEN '16+hrs'
...