Reputation: 1
Hi please can you help.
I'm trying to select the last 200 rows in my database, then compare 2 fields in each row, and return each whole row where there is only 1 instance. So, all rows that have more than 1 instance are not returned.
Is that possible in a MySQL statement or will I need to code this in PHP?
Thank you in advance
I've tried having 2 SELECT queries and creating an array of each query and comparing each element in the first array with all the elements in the second array. This hasn't worked yet (probably my poor coding skills), so I thought it may have a more elegant solution.
Thank you
Upvotes: 0
Views: 29
Reputation: 36
If you want to compare 2 columns - try "case" construction.
Somethig like:
select
case when col1 = col2 then true else false end as check_condition
from table
Then use check_condition meaning to return right strings
Upvotes: 0