xxxxxxxxxx
SELECT *
INTO NewTableName
FROM OriginalTable;
xxxxxxxxxx
SELECT column_name, COUNT(column_name) AS count
FROM table_name
GROUP BY column_name
HAVING COUNT(column_name) > 1;
xxxxxxxxxx
SELECT OrderID, COUNT(OrderID)
FROM Orders
GROUP BY OrderID
HAVING COUNT(OrderID) > 1
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
/*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
xxxxxxxxxx
ALTER TABLE Table1
ADD SubCategory2 {Type of subcategory 1} {NULL|NOT NULL}
UPDATE Table1 SET SubCategory2 = SubCategory;