Need help in one understanding the behaviour of a query.
SELECT TAB1.KEY FROM DB.TAB2
Here TAB1 and TAB2 are in Same Database(DB) and Coulmn KEY is present in both tables.
My question is, it possible pull KEY data from TAB1 by not including it in FROM CLAUSE. If so, how the query behaves?
Do we have any article or documentation on this? If yes, Could you please point me to that link?
I am working on such query where we are pulling data from another table/View but we have not mentioned that table/Veiw in FROM CLAUSE. it is working fine and I am unable to get the behaviour of it.
Thank you so much in Advance.
Yes it is possible, the bit of information that you are probably missing is that in SQL the FROM clause is optional. It is highly recommended to use it, but it is not required. See SQL DML manual for syntax diagram.
So the following two queries are identical in terms of functionality.
SELECT t1.col1; SELECT col1 FROM t1;
And with Teradata these two queries will generate the same plan.
In your example query below, the code will run but you'll get a cartesian product join between the two tables (TAB1 and TAB2).
Your query will be treated as the following:
CROSS JOIN TAB1 as a;