MySQL经验教训

MySQL语句如下:

SELECT buyer_id FROM baoxian.bc_insurance_order WHERE id in (100000422,
100000418,
100000417,
100000416,
100000415,
100000413,
100000411,
100000410,
100000409,
100000408,
100000407,
100000406,
100000404,
100000403,
100000402,
100000399);

如此简单的SQL语句,可是SQL查出来结果居然是按id升序排列的!!!因此,写SQL语句一定要把查询条件也带出来,不然谁知道MySQL自作聪明的干了什么,WTF!!!

SELECT id, buyer_id FROM baoxian.bc_insurance_order WHERE id in (100000422,
100000418,
100000417,
100000416,
100000415,
100000413,
100000411,
100000410,
100000409,
100000408,
100000407,
100000406,
100000404,
100000403,
100000402,
100000399);

另外,mysql(5.7)中varchar长度是这样的,比如varchar(7),则'http://'可以,‘一二三四五六七'也可以存,但'http://w'就超了,'一二三四五六七八'就超了。

你可能感兴趣的:(数据库)