我有下表
var A = ["Soup", "Juice", "Tea", "Others"];
var B = ["Soup", "Juice", "Water", "Others"];
var C = ["Soup", "Juice", "Coffee", "Tea", "Others"];
var select = document.getElementById('category').options.length;
for (var i = 0; i < select; ) {
document.getElementById('category').options.remove(i);
}
if (document.getElementById("meal").value == "A") {
for (var i = 0; i < A.length; i++) {
var newSelect = document.createElement('option');
selectHTML = "<option value='" + A[i] + "'>" + A[i] + "</option>";
newSelect.innerHTML = selectHTML;
document.getElementById('category').add(newSelect);
}
}
else if (document.getElementById("meal").value == "B") {
for (var i = 0; i < B.length; i++) {
var newSelect = document.createElement('option');
selectHTML = "<option value='" + B[i] + "'>" + B[i] + "</option>";
newSelect.innerHTML = selectHTML;
document.getElementById('category').add(newSelect);
}
}
else if (document.getElementById("project").value == "C") {
for (var i = 0; i < C.length; i++) {
var newSelect = document.createElement('option');
selectHTML = "<option value='" + C[i] + "'>" + C[i] + "</option>";
newSelect.innerHTML = selectHTML;
document.getElementById('category').add(newSelect);
}
}
如何获取stage_id = 1且is_completed = 1且stage_id = 2且is_completed = 0
的所有task_ids答案 0 :(得分:1)
您可以使用AND
和OR
的组合,例如:
SELECT task_id
FROM tasks
WHERE (stage_id = 1 AND is_completed = 1)
OR (stage_id = 2 AND is_completed = 2)
GROUP BY task_id;
答案 1 :(得分:0)
使用union
:
select task_id from table where stage_id = 1 and is_completed = 1
union
select task_id from table where stage_id = 2 and is_completed = 0
答案 2 :(得分:0)
来自mt_task_status的SELECT * 哪里 task_id in(SELECT task_id FROM mt_task_status WHERE stage_id ='1'和is_completed ='1') 和task_id in(SELECT task_id FROM mt_task_status WHERE stage_id ='2'和is_completed ='0') 和(1,2)中的stage_id 按task_id排序