Please try...
SELECT tblExams.srNum AS srNum,
tblExams.user_id AS user_id,
tblExams.exam_id AS exam_id,
tblExams.exam_date AS exam_date,
tblExams.exam_center_id AS exam_center_id,
tblExams.exam_shift as exam_shift
FROM tblExams
JOIN
{
SELECT user_id AS user_id,
exam_date AS exam_date,
exam_center_id AS exam_center_id,
COUNT( exam_center_id ) AS exam_center_id_count
FROM tblExams
GROUP BY user_id,
exam_date,
exam_center_id
} exam_center_counter ON tblExams.user_id = exam_center_counter.user_id
AND tblExams.exam_date = exam_center_counter.exam_date
AND tblExams.exam_center_id = exam_center_counter.exam_center_id
WHERE exam_center_counter.exam_center_id_count >= 2;
The way I have interpreted your question you are asking for records where the user has 2 or more exams in the same center on the same date. This suggested to me that the User was the most dominant factor, and within that the Exam Date, and within that the Centers and the count of Exams. Thus the GROUP BY and COUNT() lines from my inner SELECT statement.
The other three selected fields are there partly because the GROUP BY uses them and thus requires them to be part of the SELECT and partly because they are needed to form the INNER JOIN with tblExams (the name that I have assumed for your table of data). (Note : Where the word JOIN is not preceded by a join type then an INNER JOIN is performed).
The INNER JOIN has the effect here of tacking on the count of exams taking place in that Exam Center on that Date for that User onto the corresponding row(s).
Then all we need to do is select all the fields from each row from tblExams where that count is at least 2.
A variation on this logic was used when I constructed the following code for your second query...
SELECT tblExams.srNum AS srNum,
tblExams.user_id AS user_id,
tblExams.exam_id AS exam_id,
tblExams.exam_date AS exam_date,
tblExams.exam_center_id AS exam_center_id,
tblExams.exam_shift as exam_shift
FROM tblExams
JOIN
{
SELECT user_id AS user_id,
exam_date AS exam_date,
COUNT( exam_center_id ) AS exam_center_count
FROM
{
SELECT user_id AS user_id,
exam_date AS exam_date,
exam_center_id AS exam_center_id
FROM tblExams
GROUP BY user_id,
exam_date,
exam_center_id
} exam_center_id_grouper
GROUP BY user_id,
exam_date
} exam_center_counter ON tblExams.user_id = exam_center_counter.user_id
AND tblExams.exam_date = exam_center_counter.exam_date
WHERE exam_center_counter.exam_center_count >= 2;
In this query I use the inner-most SELECT statement to get a list of Exam Centers that are attended by each User on various Dates.
This data is then used by the middle-most SELECT statement to form a list of how many Centers that each User attends for an Exam on each DATE they do so.
This count is used by the outer-most SELECT to return only those rows from tblExams that meet the criteria specified.
If you have any questions or comments, then please feel free to post a Comment accordingly.
Sr.No(which I recommend changing tosrNum) is the primary key?