Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SLQ2008 Join with part of a field included in another

Status
Not open for further replies.

CarolCook

IS-IT--Management
Mar 7, 2003
158
0
0
US
Hi:
I have two tables I am trying to join. The first (call it the 'parent' table) has fields with variable length identifiers, call them abcfoo, def for instance. The second table (call it the 'child' table) has identifiers like abcfoo|123, abcfoo|345, abcfoo|456, def|123, def|246. I would like to link all fields in the child table with the parent table where the parent identifier is *part* of the child identifier.

So - update all records in the child table to match a value in abcfoo where abcfoo is part of the child string: abcfoo|123, abcfoo|345, abcfoo|456 and so on.

Thanks in advance.
 
Code:
SELECT * 
       FROM ParentTable
INNER JOIN ChildTable WHERE ChildTable.ParentId LIKE ParentTable.Id+'|%'
That is valid ONLY if ParentTable.Id is n/VARchar.
NOT TESTED!

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
And that kills me.
Why new books are cheaper than OLD ones?
34 new from $20.64 10 used from $26.87

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top