teradata sql

Tools
Enthusiast

teradata sql

i have 1 value in table1....
that one value is a field in table2....
i need to know how to access the values of the field in table2 using the value in table1?

my result should be something like

sel value(table1.field_nm) from table2;

thanks
3 REPLIES

Re: teradata sql

It appears that you would have to join the two tables. For instance,

Select table1.field1, table2.field1
form table1, table2
where table1.joinfield = table2.joinfield;

is this what you mean?
Enthusiast

Re: teradata sql

hi,
the structures and sample data contained in my 2 tables are given below
table1 contains only one column. and only one value is present in this column at a given instance.
table1
field_nm1
'tel_no'

table2
tel_no, add_no, add_res, mob_no
2222 234 1.33 56
8761 321 5.67 22

A value in table1 is a column in table2.
i need a sql query to access the values of this column(field_nm1) in table. something that functions like the below query. but the tel_no should not be used directly but must be fetched from table1.. the problem is there are no common fields bet. the 2 tables.
sel tel_no from table2;
thanks
Teradata Employee

Re: teradata sql

If I understand what you are trying to do correctly, what about this:

SELECT *
FROM TABLE2
WHERE TEL_NO = (SELECT TEL_NO FROM TABLE1);

Basically, you state that your TABLE1 has a field, TEL_NO, that is updated on occasion, and instead of hardcoding this variable value into a query, you want the query to get this value and then SELECT from TABLE2 based on it. The above query will do this.