K
K
khodos_dmitry2019-12-02 19:38:16
SQL
khodos_dmitry, 2019-12-02 19:38:16

Why does WHERE `d` = 0 select the row with value 'code: 404'?

`d` tinytext COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0',
I'm writing a query: a string with a value of 'code: 404' is selected, so it is not selected: Why?
SELECT * FROM `table` WHERE `d` = 0
SELECT * FROM `table` WHERE `d` = '0'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2019-12-02
@melkij

Because there is no need to compare strings and numbers at all. If the field is string - compare only with the string. Though thus there is also well documented behavior .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question