I write this code into my MySQL Terminal, but MySQL responses with "ERROR 1054 (42S22): Unknown column 'a.SD_ID' in 'on clause'"
I dont know why it doesnt understand my alias.
SELECT t.TBL_NAME AS 'TABLE',
t.TBL_TYPE AS 'TYPE',
a.COLUMN_NAME AS 'COLUMN_NAME',
a.TYPE_NAME AS 'TYPE'
FROM TBLS t
JOIN
(SELECT c.TYPE_NAME, c.COLUMN_NAME, c.CD_ID
FROM COLUMNS_V2 c, SDS s
WHERE c.CD_ID = s.CD_ID) a
ON t.SD_ID = a.SD_ID
WHERE t.TBL_TYPE = 'MANAGED_TABLE'
ORDER BY b.TBL_NAME, b.INTEGER_IDX;
I query this in on MySQL on a Ubuntu System.
FROM COLUMNS_V2 c, SDS s
? Comma-separated joins were made redundant in 1992. That was before MySQL even existed. Use explicit ANSI joins instead (FROM COLUMNS_V2 c JOIN SDS s ON ...
). – Thorsten KettnerSDS
at all? You are only selecting values ofCOLUMNS_V2
in the subquery. What is the purpose of the join? – Thorsten Kettner