Delete only if there is - in the word

Asked

Viewed 36 times

-1

I would like to delete some useless records from my database

They are, for example: -2046820062 -2046820165 -2046820183

In short, all records that start with the symbol - (less) of my data2 column

Example: delete

I’ve tried something like:

DELETE SUBSTRING_INDEX(data2, '-', 1) FROM tabela

but without success.

2 answers

1

Try it like this:

DELETE FROM tabela
WHERE CAST(data2 AS SIGNED) < 0

See the fiddle clicking here.

  • 1

    worked perfectly, thank you =D

-1


DELETE FROM table WHERE data2 LIKE '-%'

  • 1

    also functioned, thanks <3

Browser other questions tagged

You are not signed in. Login or sign up in order to post.