Is it possible in mysql to look for values in the varchar fields if the passed-in int value?

Suppose there is a table with a field uid VARCHAR(20). This means that the uid of the records can look like: "123","abcd","456" ....

If we make a query select * from table where uid="123" then everything will be OK, but if select * from table where uid=123 - you'll get an error because the data type does not meet the field. It is clear that we need somewhere to request to do a type cast to string, but still, theoretically, there is something universal for such a case? (regexp, like it doesn't count!)
July 8th 19 at 15:27
2 answers
July 8th 19 at 15:29
lead on working with mysql?
SELECT * FROM offers WHERE `name` = CONVERT(123, char)

although if I'm not mistaken MySQL when prompted
select * from table where uid=123
doesn't error out, and find records. However if You record will be of the form "123", "123abcd", "456" then it will return two records and "123" and "123abcd",
v 5.7 gives an error. CONVERT what you need, thank you! - tracey commented on July 8th 19 at 15:32
July 8th 19 at 15:31
to do type conversion to string

the query is a string, where other types do not. if you put quotation marks - mysql will consider it a string. if not - then no.

Find more questions by tags MySQL