

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Use to select data from another table. Use for making an alias for a column name. Example: Use to select data from another table Example: Use for making an alias for a column name. Result:
Create a table CREATE TABLE Profession ( Profession_ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY, Profession VARCHAR(30) ); 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; SELECT * FROM New_Profession; Create another new table CREATE TABLE my_students ( Student_ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY, Student_Profession VARCHAR(30) ) AS SELECT Profession AS Student_Profession FROM New_Profession GROUP BY Student_Profession ORDER BY Student_Profession; SELECT * FROM my_students; Created By: mju2022 | Feb 16,2022 | 8:32 AM | LNC Page 2