I have following table with 100 000 records:
Column FAASID has tags including parent tags, parent tag for tag 005-UPS-17999 is F-005-FRT, parent tag is defined as follows, if value from FAAAID column is the same as in FANUMB column then tag from FAASID will be parent tag. What I need is to add column with parent tag, as below:
FANUMB FAAAID FAASID Parent_tag
126697 126695 005-UPS-17999 F-005-FRT
126695 106575 F-005-FRT D-867-IHJ
106575 13456 D-867-IHJ
1条答案
按热度按时间iszxjhcz1#
You might be looking for this:
The concept is called self-referenced table where a table's FK points to another row in the same table. You can join them like you'd join other tables, but you must use aliases (
t1
andt2
here) to keep them separated.