---- ---------- | id | name | ---- ---------- | 1 | apple | | 2 | banana | | 3 | 99cat | ---- ----------
// 查询条件转化为数字1再比较 mysql> select * from product where id = '1abc23'; ---- --------- | id | name | ---- --------- | 1 | apple | ---- ---------
// 查询字段全部转化成数字,id:1和id:2字段值转化为0,id:3转化成99,再比较 mysql> select * from product where name=0; ---- ---------- | id | name | ---- ---------- | 1 | apple | | 2 | banana | ---- ----------
SELECT * FROM `mm_account` AS t1 JOIN (SELECT ROUND(RAND() * (SELECT MAX(id) FROM `mm_account`)) AS id) AS t2 WHERE t1.id >= t2.id ORDER BY t1.id ASC LIMIT 4;
SELECT * FROM `mm_account` WHERE id >= (SELECT floor(RAND() * (SELECT MAX(id) FROM `mm_account`))) and city="city_91" and showSex=1 ORDER BY id LIMIT 4;
SELECT * FROM mm_account WHERE id >= ((SELECT MAX(id) FROM mm_account)-(SELECT MIN(id) FROM mm_account)) * RAND() (SELECT MIN(id) FROM mm_account) limit 5;
SELECT * FROM `mm_account` AS t1 JOIN (SELECT ROUND(RAND() * ( (SELECT MAX(id) FROM `mm_account` where id<1000 )-(SELECT MIN(id) FROM `mm_account` where id<1000 )) (SELECT MIN(id) FROM `mm_account` where id<1000 )) AS id) AS t2 WHERE t1.id >= t2.id ORDER BY t1.id LIMIT 5;