Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

JavaWeb SQL commonly used languages (add, delete, change and search)

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. INSERT, a common parenthesis in SQL (added)

1.1 insert character type data

   needs to enclose the string with single quotation marks, and if there are single quotation marks in the value to be inserted, you need to escape with two single quotation marks'', as shown in the following figure inserting the name value into the student table:

1.2 insert date data

   needs to organize the dates in the form of years, months and days, and then enclose them in single quotation marks.

1.3 assign values to fields in the table

   creates a student table and assigns values to the id field and the name field:

1.4 insert multiple values at a time

   adds two values to the student table at a time:

2. The common query language SELECT in SQL (look up)

2.1 query all fields in the project table

(1) use wildcard to query

(2) use all fields to query

2.2 query the pid=2 students in the student1 table

2.3 Statistics on the number of pid=1 and pid=2 students in the student1 table

2.4 screen out more than 3 students' selected projects

2.5 display student information in the order of id from large to small in student1

2.6. display student information in the order from small to large id in student1, with a maximum of 4 lines

2.7 Internal connection

   is conditional on that the pid of the project table is equal to the pid of the student table:

(1) use where internal connection

(2) use intra-inner join...on connection

(3) use the alias of the table for internal join

2.8 external connection

(1) left outer connection

(2) right external connection

(3) full external connection

2.9 Cartesian product connection

2.10 query the students with the word "two" in their names and their selected items

2.11 subquery

(1) use the students with the word "two" in the name of the subquery and their selected items:

(2) subquery as Operand

(3) subquery as a condition

   ALL means all:

   ANY stands for any one:

2.12 Multi-column comparison

2.13exists keyword

   returns true when the subquery has a value, otherwise it returns false.

2.14not exists keyword

3. SQL commonly used update language UPDATE (revised)

3.1 change all pid with even id in student11 table to 1

3.2.UPDAT multiple columns, update the student pid of id5,6,7 to 2, and update the name to'0

String concatenation of new' and 'new'

Change the name of the student whose id is less than 5 to ""

4. SQL common deletion words DELETE (deletion)

4.1 Delete the data of students whose id is greater than 5 in the student1 table

4.2 points for attention

When    deletes information about a table whose primary key is referenced by another table as a foreign key, the following error occurs:

At this point,    needs to delete the table whose primary key is the foreign key, and then delete the table information before it can be deleted successfully.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report