十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
DELIMITER $$
创新互联公司成立与2013年,是专业互联网技术服务公司,拥有项目网站设计、网站建设网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元苏尼特右做网站,已为上家服务,为苏尼特右各地企业和个人服务,联系电话:18982081108
USE `test`$$
DROP PROCEDURE IF EXISTS `p_getAllTablesCount`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `p_getAllTablesCount`()
BEGIN
DECLARE tableName VARCHAR (100);
DECLARE tablesn VARCHAR (100);
DECLARE tableCount INT;
DECLARE stopFlag INT;
DECLARE sqlStr VARCHAR(1000);
-- 注意:请修改数据库名称
DECLARE cursor_name CURSOR FOR SELECT TABLE_NAME FROM information_schema.tables WHERE table_schema='test';
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET stopFlag=1;
CREATE TABLE IF NOT EXISTS temp_table(table_name VARCHAR(100),table_count VARCHAR(100));
OPEN cursor_name;
REPEAT
FETCH cursor_name INTO tableName;
SET sqlStr = CONCAT('SELECT COUNT(1) into @tableCount FROM ', tableName);
SELECT sqlStr INTO @sqlStr;
-- select @sqlStr;
SELECT @tableCount INTO tableCount;
BEGIN
PREPARE stepInsertIntoTable FROM @sqlStr;
EXECUTE stepInsertIntoTable;
END;
SET sqlStr = CONCAT('insert into temp_table values(''',CONCAT(tableName),''',''',CONCAT(tableCount),''');');
SELECT sqlStr INTO @sqlStr;
BEGIN
PREPARE stepInsertIntoTable FROM @sqlStr;
EXECUTE stepInsertIntoTable;
END;
UNTIL stopFlag END REPEAT;
CLOSE cursor_name;
SELECT table_name,table_count FROM temp_table ORDER BY table_count DESC;
-- PREPARE step FROM @sql1;
-- EXECUTE step;
DROP TABLE temp_table;
END$$
DELIMITER ;
set@num=1;或set@num:=1。
set@num=1;或set@num:=1;//这里要使用变量来保存数据,直接使用@num变量。
不好意思,只能看到您发的图,我只能粗略的模拟一下
思路: 使用 date_format() 函数 (mysql自带的函数)
(1) 创建表
create table date_test(dateofmanufacture DATE);
(2) 插入
insert into date_test values(date_format("1983-11-23", "%y-%m-%d"));
(3) 查询
select * from date_test;