分别建立三张表user,character,user_character_relation(·user_id,character_id·) 三个表中的id 字段都是自增长的;
1.需求是给uer 和character 批量添加数据
2.新增用户,并且为每个用户添加3个职业
例如 新增用户名为test 则职业名字就是test_a test_b test_c
都是需求 批量添加的~~
1.需求是给uer 和character 批量添加数据
2.新增用户,并且为每个用户添加3个职业
例如 新增用户名为test 则职业名字就是test_a test_b test_c
都是需求 批量添加的~~
解决方案 »
- Mysql的Select变量问题
- 求一个MySql存储过程,小弟以前没写过存储过程
- MYSQL root登陆的问题
- PostgreSQL-PL/pgSQL教程--基本语句
- 这条简单的SQL语句咋来优化啊?
- 查询按类别分组后每组的最新20条数据
- 请问mqsql存储过程如何输出out参数,同时php怎么得到这些out参数,谢谢!
- 郁闷中,关于MySql 中 MySqlParameter的问题,在线等
- 求助,mysql可以通过sqlplus登陆嘛?
- mycat能启动也能访问,就是日志报错
- 求修正存储过程中查询赋值的SQL语句~我是新手
- 如何处理MYSQL千W级别的数据库查询存储,涉及表关联!大神指导
delimiter//
create procedure emind()
begin
delclare i int default 0;
select conut(*) into i from user;
select i;
insert into user_character_relation(`user_id`)values(i); set i=i+1;
end while;
end;//我写的 感觉错误很多 但是还找不出在哪`
set @uid=LAST_INSERT_ID() ;insert into character values (..test_a );
set @ta=LAST_INSERT_ID() ;
insert into character values (..test_b );
set @tb=LAST_INSERT_ID() ;
insert into character values (..test_c );
set @tc=LAST_INSERT_ID() ;insert into user_character_relation values
(@uid,@ta),
(@uid,@tb),
(@uid,@tc);
你写的这个我只看懂了一部分~@uid@ta@tb@tc 都什么意思~
如果insert into character values (..test_a );
set @ta=LAST_INSERT_ID() ;
insert into character values (..test_b );
set @tb=LAST_INSERT_ID() ;
insert into character values (..test_c );
set @tc=LAST_INSERT_ID() ; 这样插入,可能是我表达不清楚吧~charcter表中的排列是test_a , test_b , test_c,test1_a tes2t_b test3_c 对应character的ID 是1 2 3 4 5 6 不知道能明白我的意思么