So, this is for debugging only. Its for looking at someone else's mess. Its not production code, it'll never see production, its not part of a wider scheme to try to do anything. Its purely debugging only.
I want to be lazy.
Overall query is something like this
SELECT
tableA."Col1"
,tableB."Col2"
,tableC."Col5"
from public."BigLongTableName" as tableA
join public."BigLongTableName2" tableB on tableB.colA = tableA.colB
join public."BigLongTableName3" tableC on tableC.colX = tableB.colY
But, due to the awful layout, not all relationships carry through and there is a web of relationships across the databases that filter out some data.
I want to be able to comment out tables without having to comment out the columns returned to GUI (they'd just not appear), so something like
SELECT
tableA."Col1"
,snazzySyntaxThatOnlyDisplaysIFHere(tableB."Col2")
, snazzySyntaxThatOnlyDisplaysIFHere(tableC."Col5")
from public."BigLongTableName" as tableA
join public."BigLongTableName2" tableB on tableB.colA = tableA.colB
--join public."BigLongTableName3" tableC on tableC.colX = tableB.colY
So, because I didn't join BigLongTableName3, tableC alias doesn't exist. Therefore the snazzySyntax would save me having to comment out that line.
Anyone any ideas off the top of their head?
I tried exists on data within tableC(), didn't like it, as tableC isn't yet declared - which makes sense. Don't know if I can make exists work directly on tableC, so tried below, no joy either - not sure if it'd work here even if it I got it right:
Select
tableA."Col1"
,if(OBJECT_ID(tableC, 'U') is not NULL); BEGIN tableC."Name"; END;