Download presentation
Presentation is loading. Please wait.
1
SQL Code for Byrnetube video
Stored Procedures SQL Code for Byrnetube video
2
SQL for people table CREATE TABLE people ( pid INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(pid), first VARCHAR(15) NOT NULL, last VARCHAR(20) NOT NULL, VARCHAR(40) NOT NULL, ) ENGINE=INNODB;
3
SQL for password table CREATE TABLE passwords ( people_id INT NOT NULL, password VARCHAR(10), FOREIGN KEY people_id REFERENCES people (pid) ) ENGINE=INNODB;
4
SQL to add 2 people to person table
INSERT INTO people (first, last, ) VALUES VALUES SELECT * FROM people
5
SQL to add passwords for people
INSERT INTO passwords VALUES (‘1’,’gtl’) VALUES (‘2’,’abs’) SELECT * from passwords
6
SQL to print the database content
SELECT * FROM people,passwords WHERE people.pid = password.people_id SELECT first, last, , password
7
Query database for first and password
SELECT first, password FROM people,passwords WHERE people.pid = password.people_id AND
8
Stored Procedure – get first and password
CREATE PROCEDURE getFirstPasswordUsing ( IN input VARCHAR(40) ) BEGIN SELECT first, password FROM people,passwords WHERE people.pid = password.people_id AND people. =input END CALL
9
Stored Procedure – create account
CREATE PROCEDURE createAccount ( IN inputFirst VARCHAR(40) IN inputLast VARCHAR(40) IN input VARCHAR(40) IN inputPassword VARCHAR(40) ) BEGIN DECLARE generatedPid INT INSERT INTO people (first, last, ) VALUES (inputFirst, inputLast, input ) SELECT pid INTO generatedPid FROM people where =input INSERT INTO password (people_id, password) VALUES (generatedPid, inputPassword) END
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.