以这两个表为例:
CREATE OR REPLACE VIEW EXAMPLE
AS
SELECT ENAME, DNAME FROM EMP, DEPT
WHERE DNAME IN ('ACCOUNTING','SALES);
我想选择在“会计”和“销售”部门工作的员工的姓名,所以我会这样做:
var stateChangingButton = L.easyButton({
states: [{
stateName: 'ButtonOff',
icon: 'X',
title: 'Turn Button On',
onClick: function(btn, map) {
btn.button.style.backgroundColor = 'red';
btn.state('ButtonOn');
map.on('mousedown', getClickLocation);
map.on('mouseup', getReleaseLocation);
map.on('mouseup', toGeoJsonBounds);
map.on('mouseup', addSelectionLayer);
map.on('mouseup', addColorSelection);
}
}, {
stateName: 'ButtonOn',
icon: 'X',
title: 'Turn Button Off',
onClick: function(btn, map) {
btn.state('ButtonOff');
btn.state('ButtonOff');
btn.button.style.backgroundColor = 'white';
map.off('mousedown', getClickLocation);
map.off('mouseup', getReleaseLocation);
map.off('mouseup', toGeoJsonBounds);
map.off('mouseup', addSelectionLayer);
map.off('mouseup', addColorSelection);
}
}]
});
stateChangingButton.addTo(map);
但我完全不确定这是否正确。我应该使用dname加入ename
在哪里ename.dname IN('ACCOUNTING','SALES')可能?
提前谢谢
答案 0 :(得分:0)
您应该通过DEPTNO列加入EMP表和DEPT表。 之后使用条件WHERE DNAME IN('ACCOUNTING','SALES') 查询如下所示:
SELECT e.ENAME, d.DNAME
FROM EMP e
left join DEPT d on d.DEPTNO = e.DEPTNO
WHERE d.DNAME IN ('ACCOUNTING','SALES');