If I have a table with only one column, how could I delete a particular row from it? I know the most logical answer would be to have another column in the table with a number that automatically increments, but in a table with only one column, how would I go about doing this? Is there something I can add in the WHERE clause to say row = 3 or something similar?
Asked
Active
Viewed 637 times
0
-
1No. You can only delete a row based on the values in the row. – Gordon Linoff May 03 '17 at 02:11
-
Does this question help? http://stackoverflow.com/questions/1466963/sql-row-number-function-in-where-clause – AJ X. May 03 '17 at 02:14
-
What you can do is create another column, fill it with sequencial data, index it (not really needed, but it will be better) then delete based on this new row. – Jorge Campos May 03 '17 at 02:17
-
Is the target value unique or are you willing to delete *all* rows with that value? – toonice May 03 '17 at 02:25
-
It's unique, only the one row should be deleted. – Brit24 May 03 '17 at 02:28
2 Answers
0
You can do:
delete t from t
where col = @value;
However, that will delete all rows with the value. If the value is unique, you should declare the column to be either unique or a primary key.
I should add that you can delete just one row with the value by adding limit 1
:
delete t from t
where col = @value
limit 1;

Gordon Linoff
- 1,242,037
- 58
- 646
- 786
-
So does col mean column? Where you have "where col = @value" is col referring to column within SQL? – Brit24 May 03 '17 at 02:55
-
0
Please try the following...
DELETE FROM tblTable
WHERE fieldName = targetValue;
If you have any questions or comments, then please feel free to post a Comment accordingly.

toonice
- 2,211
- 1
- 13
- 20