求助:sql 结果集 两个表的同名字段 能否合并为一行
-- 根据人员所在区域查出该部门的所有考勤设备
SELECT
dbi.id, dbi.`NAME`, dbi.LOCATION_ID, dai.ALGORITHM_VERSION, dgi.ALGORITHM_VERSION, dai.DOMAIN_ID
FROM
DEVICE_BASIC_INFO dbi
LEFT JOIN device_attendance_info dai on dbi.ID = dai.DEVICE_ID
LEFT JOIN device_gatemachine_info dgi on dbi.ID = dgi.DEVICE_ID
WHERE
1 = 1
AND dbi.IS_USED != 2
AND dbi.LOCATION_ID = 349
AND (dbi.DEVICE_TYPE = 1 OR dbi.DEVICE_TYPE = 14)
;
|id | name | dep | a.ver | b.ver | domain | |------ | ------ | ------ |------ |------ |------ | |366 |GMReader|349 | - |v3.3.1 | - | |427 |KQ_01 |349 |5.8 | - |322 |
请大侠指教,谢谢
1
TommyLemon 2018-11-03 23:25:17 +08:00
合并为一行是什么意思?一起查出来(数据库支持,但 JSON 不支持,得 AS 取别名) 还是合并为一个字段( CONCAT(a, b) )?
|