SQL entry classic summary

After completing the previous stage of learning, I started the next stage of learning. The book with more than one hundred pages still doesn’t seem to be easy to grasp the key points. At first glance, it was full of words. My master told me the key points and hit the key points on the blackboard. Ah, inserting, updating and deleting data are very important. Just see us today. Let’s summarize it.
Insert data: INSERT INTO
update data: UPDATE
delete data: DELETE
insert data
Basic syntax: INSERT INTO table_name (column_names) VALUES (data_values)
INSERT INTO Table name (column name) VALUES (data item)
example: INSERT INTO Category (CategoryId, Category) VALUES (1,'Thriller');
INSERT INTO Category (CategoryId, Category) VALUES (2,'Romance');
INSERT INTO Category (CategoryId, Category) VALUES (3,'Horror');
SELECT * FROM Category (check whether the data in the table is correct)

Update data
Basic syntax: UPDATE table_name
SET column_name = value
WHERE condition,
specify the name of each column in the SET statement and the new data that each column should store

Delete data
Basic syntax: DELETE FROM table_name
Example:
delete all data: DELETE FROM MemberDetails;
delete some data: DELETE FROM Member Details WHERE MemberId = 4; use WHERE clause to formulate

1. Logical operators AND and OR (this thing is linked to my profession, and I also need to design the circuit)
AND (the left and right conditions must be true)
WHERE MyColumn = 132 AND MyOtherColumn ='TEST'
OR (when When one expression is true or both expressions are true, the condition is true and the record is updated)
WHERE MyColumn = '10' OR MyOtherColumn ='TEST'

Guess you like

Origin blog.csdn.net/weixin_45706856/article/details/107051581