Hi all, I am not over familiar with SQL, I am a VB programmer, simply I need to achieve the following within Enterprise Manager.
I have 2 tables, different designs, different number of rows, I simply need to check whether the contents of a column in the first table is in a column in the second table, just simply a table/column to table/column data check for the same data content.
Easy Peasy for you guys, any help would be appreciated.Hi all, I am not over familiar with SQL, I am a VB programmer, simply I need to achieve the following within Enterprise Manager.
I have 2 tables, different designs, different number of rows, I simply need to check whether the contents of a column in the first table is in a column in the second table, just simply a table/column to table/column data check for the same data content.
Easy Peasy for you guys, any help would be appreciated.
Welcome to the forum,ok here is your solution
CREATE TABLE t1(
col1 VARCHAR(20)
,col2 VARCHAR(20)
,col3 VARCHAR(20)
)
CREATE TABLE t2(
col4 VARCHAR(20)
,col5 VARCHAR(20)
)
The sql statement to check content of a col1 is in col4 or not...
SELECT * FROM
t1,t2
WHERE t1.col1=t2.col4|||Many thanks, will give it a try a wee bit later and post result.
Many thanks...|||Hi, this appears to work fine, however if I change the logic to check what is not in table2 it appears to go into a endless loop, any help appreciated.|||Hi, sorry after further testing, I may not have explained myself very well, apologies, I need to access row1 of table1 and then scan column2 in table2, the entire table, for the occurence of the data item in row1 table1.
Many thanks in anticipation.|||Hi, this appears to work fine, however if I change the logic to check what is not in table2 it appears to go into a endless loop, any help appreciated.
Test it ...
insert into t1 values('joy','datta','harry')
insert into t1 values('Pink','datta56','harry2')
insert into t1 values('Sheep','datta5','harry3')
insert into t1 values('Ghree','datta11','harry5')
insert into t2 values('Sheep','datta5')
insert into t2 values('Ghree','datta11')
SELECT * FROM
t1
WHERE t1.col1 NOT IN(SELECT t2.col5 FROM t2)|||Thanks sorted..
No comments:
Post a Comment