0

I have a table with below data. In which I want to assign unique id to combination of two columns(emailid and collegeid) with or condition.

In the case of emp "1" and emp "2" has the same emailid but different collegeid still they are linked to each other by the emailid only.

In the case of emp "1" and emp "3" has the same collegeid but different emailid still they are linked to each other by the collegeid only.

In the case of emp "2" and emp "7" has the same collegeid but different emailid still they are linked to each other by the collegeid only.

All above empid are linked to each other through either emailid OR collegid, my desired output will be to assign same rownumber to all linked empid.

empid emailid collegeid row_number(**Desired Output**)
----------------------------------
1,  n@gmail.com,    22, 1
2,  n@gmail.com,    34, 1
3,  k@gmail.com,    22, 1
4,  p@gmail.com,    45, 2
5,  m@gmail.com,    78, 3
6,  m@gmail.com,    98, 3
7,  s@gmail.com     34, 1
8,  j@gmail.com,    48, 4
9,  a@gmail.com     48, 4

Note :- I have 50 Millions records in my mysql table.

Nishant Gupta
  • 21
  • 1
  • 6
  • You've tagged this for Oracle but then mention MySQL - which is it? I also don't understand how you get to the desired results - you're looking for *any* link between those three columns leading to the same row number (or some other rank)? – Alex Poole Feb 11 '20 at 17:53
  • my bad, mistakenly I tagged oracle instead of mysql. Row_number column is just for desired output example. – Nishant Gupta Feb 11 '20 at 18:05

0 Answers0