Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- delimiter //
- create procedure setBooks()
- begin
- set @i = 1;
- loop1: loop
- set @authorId = (
- select id from authors order by rand() limit 1
- );
- set @themeId = (
- select id from themes order by rand() limit 1
- );
- insert into books (
- name, pages, price, publishDate, authorId, themeId
- ) values (
- concat('book', @i), floor(rand() * 500) + 20,
- rand() * 500000 / 100 + 100,
- current_timestamp(), @authorId, @themeId
- );
- set @i = @i + 1;
- if @i > 500 then leave loop1; end if;
- end loop loop1;
- end//
- delimiter ;
- call setBooks();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement