时间:2021-07-01 10:21:17 帮助过:2人阅读
例子如下:
CREATE TEMPORARY TABLE NEW_TIME_CLIENT(UUID VARCHAR(36), CLIENT_MAC VARCHAR(17), ONLINE_SECONDS INT)
ENGINE=MEMORY;
SET @SQL_NEW_TIME_CLIENT=CONCAT("
INSERT INTO NEW_TIME_CLIENT
SELECT UUID, SUBSTRING(RVALUE,1,17) CLIENT_MAC, SUBSTRING(RVALUE,19) ONLINE_SECONDS FROM
(
SELECT * FROM VALUE_DETAIL_5_42_",@CUR_DAY,"
WHERE RPTTIME BETWEEN ‘",@TIME1,"‘ AND ‘",@TIME2,"‘) R
WHERE RITEM LIKE ‘client%‘;");
PREPARE SQL_NEW_TIME_CLIENT FROM @SQL_NEW_TIME_CLIENT;
EXECUTE SQL_NEW_TIME_CLIENT;
在MySQL中拼SQL语句
标签:mysql sql 拼sql