I want to get duplicate data in the id_time_slot field with the value "7" ?
Asked
Active
Viewed 70 times
-3

Barmar
- 741,623
- 53
- 500
- 612

Rivaldi Setiawan
- 11
- 2
-
2Please post code and data as text, not images. – Nick Jan 03 '20 at 03:21
-
2Your question isn't clear. Do you want a query that finds all the rows that have duplicate `id_time_slot`? – Barmar Jan 03 '20 at 03:31
-
If that's what you want, this is a duplicate of https://stackoverflow.com/questions/24738346/find-rows-with-duplicates-in-three-columns-without-specifying-value – Barmar Jan 03 '20 at 03:35
2 Answers
0
Salam, try to add this:
Select * from // before your sql request
// all your sql request
where id_slot_time = 7; // the end
You will make a Select on your current result table ( a new table) that will give you what you want.

Ṃųỻịgǻňạcểơửṩ
- 2,517
- 8
- 22
- 33

Wassim Benkoulal
- 3
- 1
-
if I add a "where id_slot_time = 7", it will display 2 data. I only want to display 1 data only – Rivaldi Setiawan Jan 03 '20 at 04:09
0
Use subquery GROUP BY schedule_number, id_slot_time HAING COUNT(*) > 1
to get the duplicated records
in group like this:
SELECT tb1.*
FROM (
SELECT
tb_schedule_detail.*
FROM
tb_schedule_detail
JOIN tb_scheduler ON tb_scheduler.scheduler_number = tb_schedule_detail.scheduler_number
WHERE
dock_id = 2
AND tb_schedule_detail.rdd = '2020-01-02'
GROUP BY tb_schedule_detail.schedule_number
) AS tb1
GROUP BY tb1.schedule_number, tb1.id_slot_time
HAVING COUNT(*) > 1

TsaiKoga
- 12,914
- 2
- 19
- 28