

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
My SQL - Creating A New Table With Primary Key and Data Coming From Other Table
Typology: Study notes
1 / 3
This page cannot be seen from the preview
Don't miss anything!
Result: Syntax Explained: CODES Create the first table CREATE TABLE Profession ( Profession_ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY, Profession VARCHAR(30) ); Insert values onto the first table INSERT INTO Profession VALUES(null,'Doctor'); INSERT INTO Profession VALUES(null,'Nurse'); INSERT INTO Profession VALUES(null,'Teacher'); INSERT INTO Profession VALUES(null,'Police'); INSERT INTO Profession VALUES(null,'Painter'); INSERT INTO Profession VALUES(null,'Photographer'); SELECT * FROM Profession; Create a new table CREATE TABLE New_Profession ( Profession_ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY, Profession VARCHAR(30) ) AS SELECT Profession FROM Profession GROUP BY Profession ORDER BY Profession; Page 2