Suppose I have columns col1, col2, col3, col4 in myTable and I need to print out the values exclusive to only one column .
So if the above looks like
col1 col2 col3 col4
s e c b
c c a s
n s e a
d d q c
Then the output should be n, q b since they are exclusive only to col1, col3 and col4 respectively.
How can I achieve this through a query in mysql php?
EDIT The duplicates dont have to be in a single row .I have changed the the table layout now to make it clear.
If you are looking for a SQL-only solution, you can do a query per column like this:
It’s possible to combine all four queries with
UNIONbut that may not be necessary depending on what you want to do with the data. Also, this query should not perform very well with large datasets.