在SQL查询中添加千位分隔符

时间:2017-08-22 15:30:12

标签: mysql

我必须处理这样的查询:

SELECT some_col FROM some_table WHERE id BETWEEN 0 AND 50000000;

如果边界值可以用不同的方式表达,那么读取代码会更容易,例如:

SELECT some_col FROM some_table WHERE id BETWEEN 0 AND 50 000 000;
SELECT some_col FROM some_table WHERE id BETWEEN 0 AND 50M;

这可能吗?

1 个答案:

答案 0 :(得分:0)

这有效:

SELECT some_col FROM some_table WHERE id BETWEEN 0 AND REPLACE('50 000 000', ' ', '');
SELECT some_col FROM some_table WHERE id BETWEEN 0 AND REPLACE('50M', 'M', '000000');