I have a MySQL table and it has 2 columns which record users' login info:
User_id Device_id
a 123
b 123
b 321
d 321
e aaa
f ccc
g cba
h aaa
h ccc
i cba
i aaa
Now I want to add a column Group: if user_id are logined by the same group of device, then put them together. For instance, as shown below, user account a and b are logined on device 123, so a and b are in the same group. While user account b is also logined on device 321, then all accounts logined by 321 should join this group
:
User_id Device_id Group
a 123 1
b 123 1
b 321 1
d 321 1
e aaa 2
f ccc 2
g cba 2
h aaa 2
h ccc 2
i cba 2
i aaa 2
This cannot be simply dealed with group by so how to use SQL to express column Group?
MySQL8.5MySQLtable toHadoopplatform and deal it withHiveand query grammar there is much more flexible. So difference betweenMySQLversions is actually not a big deal. You can use the version you like most :-)