SELECT
This is our table we will use SELECT on
CREATE TABLE student(
student_id INT AUTO_INCREMENT,
name VARCHAR(20),
major VARCHAR(20),
PRIMARY KEY(student_id)
);
INSERT INTO student(name,major) VALUES('John','Biology');
INSERT INTO student(name,major) VALUES('Kate','Sociology');
INSERT INTO student(name,major) VALUES('Claire','Chemistry');
INSERT INTO student(name,major) VALUES('Jack','Biology');
INSERT INTO student(name,major) VALUES('Mike','Computer Science');
SELECT * FROM student;
We already have used
SELECT *
FROM student;
Which selects all the columns and rows from a table
Specify specific columns by placing their names after
SELECT, Seperate them with commas
SELECT name , major
FROM student;
You can prepend the columns with the specific table, (** this will come in handy when working with multiple tables)
SELECT student.name, student.major from student;