I have a table say table1 with three columns lets name them col1 col2 and col3. I have a suspicion that col2 and col3 have some values that are identical i.e. to say there are some rows where col2 = col3. In case, if for these rows col1 is the same I will have no problem in my application. But how to check for those where col1 = col2 but they don't point to the same col1 value.
SELECT * FROM table1 WHERE col2 = col3 gives me records for col2 = col3 in same rows. what I want for each col2 value search col3 if it is same send those records
Something like this (this is pseudo SQL) but in MYSQL
SELECT DISTINCT col2 FROM table1
same_records = SELECT DISTINCT col1 FROM table1 WHERE col2 = col3
records UNION same_records
Is there is a way to get these results (if they exist)? I believe that I have to use self-join on the table.