Querying a string from int column?

前端 未结 4 1864
眼角桃花
眼角桃花 2020-12-20 17:55

I have a table:

CREATE TABLE `ids` (
    id int(11) not null auto_increment,
    PRIMARY KEY (id)
);

It contains some IDs: 111, 112, 113, 1

4条回答
  •  一整个雨季
    2020-12-20 18:46

    lame + kills optimization but serves it purpose

    SELECT * FROM `ids` WHERE concat(id) = '112abcdefg';
    

    that way you enforce casting to string http://dev.mysql.com/doc/refman/5.1/en/type-conversion.html

提交回复
热议问题