I am a beginner in MySQL. Here I had just created a table
CREATE TABLE Student (
Rollno int,
LastName varchar(255),
FirstName varchar(255),
Gpa float,
);
Once after creating the table I had added the values with the help of the below query
USE persons;
INSERT INTO student
VALUES
(1, 'Aa', 'A', 8.5),
(2, 'Bb', 'B', 8.6),
(3, 'Cc', 'C', 8.7),
(4, 'Dd', 'D', 8.4);
I had just run the above query twice which resulted in having two entries as shown below
So I just wanted to remove the duplicate entries and the resultant database should resemble as
Though I searched and tried I don't possess any unique values like id
mentioned in this answer.
And again I tried with the help of this answer the code is shown below
WITH cte AS (
SELECT
Rollno,
LastName,
FirstName,
Gpa,
ROW_NUMBER() OVER (
PARTITION BY
Rollno
ORDER BY
Rollno
)RN
FROM
persons.student
)
DELETE FROM cte
WHERE RN > 1;
but the above throws error stating
Error Code:1288. The target table cte of the DELETE is not updatable
So I just wanted an optimal solution to have single entries in the table.