Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

My SQL - Creating A New Table With Primary Key and Data Coming From Other Table, Study notes of Computer Engineering and Programming

My SQL - Creating A New Table With Primary Key and Data Coming From Other Table

Typology: Study notes

2021/2022

Available from 02/16/2022

jean-undang
jean-undang 🇵🇭

11 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
STEPS:
1. Create a Table. Skip this step if you've already created a table.
2. Insert values into the table.
Result
3. Create a new table.
Page 1
MySQL
How to Create a Table with Primary Key then Insert
Data from Another Table
pf3

Partial preview of the text

Download My SQL - Creating A New Table With Primary Key and Data Coming From Other Table and more Study notes Computer Engineering and Programming in PDF only on Docsity!

STEPS:

  1. Create a Table. Skip this step if you've already created a table.
  2. Insert values into the table.

Result

  1. Create a new table.

Page 1

MySQL

How to Create a Table with Primary Key then Insert

Data from Another Table

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