1

Test table in the database looks like

id - int
title - varchar
+---+-------+
| id| title |
+---+-------+
|1  | name  |
+---+-------+

I run the query SELECT * FROM `Test` WHERE id="1abc"

Then it gives the output as

+---+-------+
|1  | name  |
+---+-------+
3
  • 1
    That's becouse id is integer, so, "1abc" will be convert to 1 Commented Aug 20, 2019 at 9:04
  • but "1abc" is not an integer Commented Aug 20, 2019 at 9:06
  • 2
    1 = '1', ' 1', or '1a' Commented Aug 20, 2019 at 9:11

1 Answer 1

2

The Type Declared in ID is an Integer.

when you pass in a string beginning with a number, it would assume you are tyring to input a number value. Thus converting the value to an integer (the first letter in your string)

the warning message would appear as something like

Truncated incorrect DOUBLE value: "1abc"

Type Conversion Documentation

Sign up to request clarification or add additional context in comments.

1 Comment

Also to add, if you run select convert('13deee2rf' , unsigned int); it will return you 13. hopefully this is clear

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.