sql - MySQL finding duplicate items in a row -


i wanna ask if possible make query see duplicate items between 2 tables? i've tried solutions returns duplicated rows not duplicated items.

for example, have these 2 tables:

table_a

| | b | c | d |

..........................................

| door | book | keys | shoe |

| door | bags | desk | keys |

| rice | fish | cake | shoe |

table_b

| | b | c | d |

| tape | fans | robe | spec |

| keys | shoe | fans | room |

| hall | pops | door | disc |

so, in end returns items has duplicates. example,

| door |

| keys |

| shoe |

.....

i've tried few queries still can't find solution. thanks.

you can unpivoting data , using group by:

select col (select col table_a union       select b table_a union       select c table_a union       select d table_a union       select table_b union       select b table_b union       select c table_b union       select d table_b      ) t group col having count(*) > 1; 

if table large, there more efficient ways unpivot using union all.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -