Javaweb SQL Common Language (add and revise)

Source: Internet
Author: User

1, SQL commonly inserted insert (increment)

1.1 Inserting character type data
You need to use single quotes ' to enclose a string, and if there is a single quote in the value you want to insert, you need to escape by using two single quotes ', such as inserting a name value into the student table:

1.2 Inserting date-type data
You need to organize the date in the form of a month and day, and then enclose it in single quotation marks.

1.3 Assigning values to fields in a table
Create a student table and assign a value to the ID field and the Name field:

1.4 Inserting multiple values at once
Add two values to the student table at a time:

2, SQL Common Query Language select (check)

2.1 Querying all fields in the project table
(1) query with wildcard characters

(2) Query with all fields

2.2 Querying pid=2 students in the Student1 table

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

2.4 Screening of more than 3 student-selected projects

2.5 Display student information in the order of Student1 from the big to the small

2.6 Display student information in order from small to large in student1, up to 4 rows

2.7 Internal Connection
The PID of the project table is equal to the PID in the student table:
(1) Connect in where

(2) Use inner Join...on inner connection

(3) Internal connection with the alias of the table

2.8 External Connection
(1) Left outer connection

(2) Right outer connection

(3) Full-outer connection

2.9 Cartesian product connections

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

2.11 Sub-query
(1) Use the subquery with the word "two" in the name of the student and the selected items:

(2) Sub-query as operand

(3) Sub-query as condition
All means all:

Any represents any one of the following:
2.12 Multi-column comparison

2.13exists keywords

2.14not exists keywords

3, SQL Common Update language updates (change)

3.1 Change all PID with an even number in the Student11 table to 1

3.2 Update multiple columns to update id5,6,7 's student PID to 2,name update to ' 0
string concatenation of new ' and ' new '


3.3 Change the name of the student whose ID is within 5 to "haha"

4, SQL commonly deleted delete (deleted)

4.1 Delete data for students with IDs greater than 5 in the Student1 table

4.2 Precautions
When you delete information for a table that has a primary key referenced by another table as a foreign key, the following error occurs:

You must first delete the table that references the table's primary key as a foreign key, and then delete the table information before it can be deleted successfully.

Javaweb SQL Common Language (add and revise)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.