Table 1
DataValue TokenIndex
AB NULL
TABLE 2
TokenIndex TokenValue
1 AB
2 ABAC
i want to update my table1 (TokenIndex) with the (TokenIndex) of table2 where table1 (DataValue) (sql LIKE) with (TokenValue)
TABLE 2 with longest string
EG. AB like like AB,and ABAC also but i want 'ABAC' TokenIndex (which is 2) to update in Token index of Table 1 against AB
i want retult
Table 1
DataValue TokenIndex
AB 2
Loading

Arul Manivannan48 reputationPosted Mar 20, 2013, 10:06 PM EDT
Your result example seems to be more clearer than other explanations. But why did you want to update table1's record with Table2's Tokenindex = 2 and why not Tokenindex = 1. What is the pattern behind it. Solution is easy by tweaking update query but By clarifying this i only we can have proper solution.
Arul Manivannnan
sakshi goyal2 reputationPosted May 9, 2013, 10:48 PM EDT
where table2.TokenValue like 'AB%' and tokenvalue not like 'AB'
Ruchi H105 reputationPosted Jul 22, 2013, 10:17 PM EDT
You can use this query
Update Table1
Set TokenIndex=(
Select Table2.TokenIndex From Table2, Table1
Where TokenValue like [DataValue] || '_%'
)
for updating all the rows
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 22, 2013, 10:35 PM EDT
Try like this
Regards,
Iftikar