MySQL Forums
Forum List  »  Perl

compare 2 columns with wildcard
Posted by: Mark Li
Date: June 23, 2009 09:22AM

Hi all,
I have 2 tables.i.e. Table1 and Table2.

Table1
---------------
Code
---------------
a_b
c_d
e_f
f_g

Table2
------------
Msg
------------
s_c_d_1
r_a_b_o
t_f_g_k
A_e_f_D

I want to compare the two columns of the respective Tables and get the output as..

Table2
----------------------
Msg || Code
---------------------
s_c_d_1 || c_d
r_a_b_o || a_b
t_f_g_k || f_g
A_e_f_D || e_f

That is i want to check which code is for which Msg and then update the Table2.code column.

I tried to implement this by...

UPDATE Table2.Code SET Table2.Code =(SELECT Table1.Code, Table2.Msg FROM Table1, Table2 WHERE Table1.Code LIKE Table2.Msg);

I even tried by

UPDATE Table2.Code SET Table2.Code =(SELECT Table1.Code, Table2.Msg FROM Table1, Table2 WHERE Table1.Code LIKE "'%' + Table2.Msg + '%'");

But still its not working...

Please guide me in this....
Thanking you!!!

Options: ReplyQuote


Subject
Written By
Posted
compare 2 columns with wildcard
June 23, 2009 09:22AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.