Answer the question
In order to leave comments, you need to log in
How to select records with the same value in a column?
The table has the following fields:
id, sum, member_id, date, operator_id Can
you tell me how to select all records whose date and operator_id fields are the same, have the same values?
Answer the question
In order to leave comments, you need to log in
For example like this. I posted it right here, I hope there are no mistakes :)
SELECT `test`.*
FROM `test`
LEFT JOIN
(SELECT `date`, `operator_id`
FROM `test`
GROUP BY `date`, `operator_id`
HAVING COUNT(*)>1) as `tbl`
ON
`test`.`date`=`tbl`.`date` AND
`test`.`operator_id` = `tbl`.`operator_id`
WHERE `tbl`.`date` IS NOT NULL
here is my version
select t1.*
from test t1
where exists (select *
from test t2
where t2.id <> t1.id
and t2.date = t1.date
and t2.operator_id = t1.operator_id)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question