在结果列中连接表时遇到问题。我有一个有效的查询,该查询使用UNION合并了不同的表,但是当我扩展另一个表时,出现了一条错误消息:“所用的SELECT语句具有不同的列数”
这是我的查询
(SELECT
IDNumber,
CONCAT(LastName, ', ', FirstName, ' ', Middle) as Name,
CONCAT(EmDesignation, ', ', Department) as Information,
Image,
v.PlateNo as PlateNumber
FROM
tblemployee as e, tblvehicle as v
WHERE
v.RFIDNo LIKE '6424823943'
AND
e.RFIDNo LIKE '6424823943')
UNION
(SELECT
IDNumber,
CONCAT(LastName, ', ', FirstName, ' ', Middle) as Name,
CONCAT(Course, ', ', Year) as Information,
Image,
v.PlateNo as PlateNumber
FROM
tblstudents as s, tblvehicle as v
WHERE
v.RFIDNo LIKE '6424823943'
AND
s.RFIDNo LIKE '6424823943')
我对此有疑问。 上面的继续查询
UNION
(SELECT
Barrier
FROM
tblinformation as inf
WHERE
inf.RFIDNo IN (6424823943)
ORDER BY
AttendanceNo DESC LIMIT 1)
答案 0 :(得分:0)
该错误消息指出了问题所在。只需提高SELECT中的列数,它将可以正常工作。
答案 1 :(得分:0)
错误消息是正确的。将class App : AppCompatActivity()
添加到第二个查询中以匹配列号,它将起作用。
例如:
NULL