RAWDATA Assignment 2 - Querying IMDB With SQL: Use Your Account On Wt-220.ruc - DK
RAWDATA Assignment 2 - Querying IMDB With SQL: Use Your Account On Wt-220.ruc - DK
Question a)
The following SQL-query counts the numbers of movies Kevin Bacon has
participated in.
Question b)
Write a procedure, movies(actor_name), that returns the titles of movies the
actor actor_name, has participated in. Thus
should return the list of titles that Mads Mikkelsen has acted in.
Question c)
Write a procedure that takes a string as input and find the 10 most recent movies
with a title that match the string.
Question d)
The following SQL-query retrieves the roles that Kevin Bacon has participated in.
SELECT name,roles(name)
FROM imdb.name where name like 'De Niro, R%';
Hint: Use a cursor and loop through the query-result to assemble the string. The
concat-function can be used for this purpose.
delimiter //
create function hello (s char(20))
returns char(50)
begin
return concat('hello, ',s,'!');
end;//
delimiter ;
call myfirst();
call mysecond();
select hello(name) from university.instructor where
dept_name='Comp. Sci.';
+ ------------- +
| count(*) |
+ ------------- +
| 3570524 |
+ ------------- +
1 rows
Execute:
> call mysecond()
+ --------- +
| name |
+ --------- +
| Vargas, Freddy |
| Vargas, Fred |
| Vargas, Fredy |
+ --------- +
3 rows
Execute:
> select hello(name) from university.instructor
where dept_name='Comp. Sci.'
+ ---------------- +
| hello(name) |
+ ---------------- +
| hello, Srinivasan! |
| hello, Katz! |
| hello, Brandt! |
+ ---------------- +
3 rows