How to delete only one row if several found?

Viewed 14766

I have a table that looks like this.

CREATE TABLE tshirt
(
  id serial,
  sku character varying(255) NOT NULL
);

I want to delete only one row with my wanted sku, but DELETE FROM tshirt WHERE sku='%s'; deletes all entries with that sku. How can I do this ?

5 Answers

This SQL Server DELETE TOP example would delete the first record from the employees table where the last_name is 'Anderson'. If there are other records in the employees table that have a last_name of 'Anderson', they will not be deleted by the DELETE TOP statement.

DELETE TOP(1)
FROM employees
WHERE last_name = 'Anderson';
Related