xxxxxxxxxx
-- Assuming you have a table called `your_table` with columns: `column1`, `column2`,
-- Insert query to duplicate the row with a specific condition
INSERT INTO your_table (column1, column2, )
SELECT column1, column2,
FROM your_table
WHERE your_condition;
-- Example: Duplicate the row with ID = 1
INSERT INTO your_table (column1, column2, )
SELECT column1, column2,
FROM your_table
WHERE ID = 1;
xxxxxxxxxx
Multiple field=
SELECT username, email, COUNT(*)
FROM users
GROUP BY username, email
HAVING COUNT(*) > 1
Single field=
SELECT _column, COUNT(*)
FROM _table
GROUP BY _column
HAVING COUNT(*) > 1
xxxxxxxxxx
SELECT column1, column2, COUNT(*)
FROM table_name
GROUP BY column1, column2
HAVING COUNT(*) > 1;
xxxxxxxxxx
SELECT column_name, COUNT(*)
FROM table_name
GROUP BY column_name
HAVING COUNT(*) > 1;
xxxxxxxxxx
SELECT OrderID, COUNT(OrderID)
FROM Orders
GROUP BY OrderID
HAVING COUNT(OrderID) > 1
xxxxxxxxxx
/*SELECT hotel_id, reservation_id, COUNT(hotel_id)FROM staywhere reservation_id is not nullGROUP BY hotel_id, reservation_idHAVING COUNT(hotel_id) > 1*/select distinct s.hotel_id , t.* from stay sright join ( select hotel_id, reservation_id, count(*) as qty from staywhere reservation_id !=1 group by hotel_id, reservation_id having count(*) > 1) t on s.hotel_id = t.hotel_id and s.reservation_id = t.reservation_id