SELECT range of integers in MySQL. Eg. 1,2,3,4,…,n;
问题 I need to select range of integer in MySQL. Something like this SELECT RANGE(10,20) AS range; returns 10, 11, 12, 13, 14, ..., 20 Why? I would like to select random phone number from range which is not yet registered. This is idea. SELECT RANGE(100000,999999) AS range FROM phone WHERE phoneNum <> range LIMIT FLOOR(100000 + RAND()*(899999); 回答1: Problems with your query: You can't use range in the WHERE clause. It is an alias and will only be defined after the WHERE clause is performed. Even