当前位置:网站首页>Nodejs database (Part 2)
Nodejs database (Part 2)
2022-06-11 07:00:00 【Yu Mei】
1.SQL Of select sentence
1.1 Grammar introduction
- SELECT Statement is used to query data from a table , The results of the execution are stored in a result table ( Called result set )

- Be careful :SQL Keywords in statements are case insensitive
- When executing a statement , You need to select the default database , Double click to select the specified database
1.2 Demonstrate two SELECT sentence
Query all column writing methods
from users Select all the columns in the table , You can use symbols * Replace the name of the column
SELECT Column name
Get the name username and password The contents of the column ( From the name users Database table of )
2.SQL Of insert into sentence
grammar : Used to insert new data rows into the data table

Be careful : New data needs to be quoted , Otherwise, an error will be reported
3.SQL Of update sentence
grammar :Update Statement is used to modify the data in the table

Between multiple updated Columns , Use English commas to separate
where Followed by the updated conditions
Be careful : Beginners often forget to provide updated where Conditions , This will cause the data of the whole table to be updated , Be careful
4.SQL Of delete sentence
- grammar :DELETE Statement to delete rows in a table

5.where Clause
- WHERE Clause is used to limit the selection criteria . stay SELECT、UPDATE、DELETE In the sentence , Can be used WHERE Clause to limit the selection criteria

2. Can be found in WHERE Operators used in Clauses

- Can pass WHERE Clause to qualify SELECT Query criteria for
-- Inquire about id by 1 All users of
select * from users where id=1
-- Inquire about id Greater than 2 All users of
select * from users where id>2
-- Inquire about username It's not equal to admin All users of
select * from users where username<>'admin'
6.SQL Of AND and OR Operator
- AND and OR Can be found in WHERE The combination of two or more conditions in a sub statement
- AND Indicates that multiple conditions must be met at the same time , amount to JavaScript Medium && Operator , for example if (a !== 10 && a !== 20)
- OR It means that as long as any condition is satisfied , amount to JavaScript Medium || Operator , for example if(a !== 10 || a !== 20)
- Case code
-- and
-- Use AND To display all status by 0, also id Less than 3 Users of
select * from users where status=0 and id<3
-- or
-- Use OR To display all status by 1, perhaps username by zs Users of
select * from users where status=0 or username='zs'
7.SQL Of order by Clause
- grammar
- ORDER BY Statement to sort the result set according to the specified column
- ORDER BY By default, statements sort records in ascending order ,ASC Keywords represent ascending sorting
- If you want to sort records in descending order , have access to DESC keyword
- ORDER BY Clause - Ascending sort
Yes users Table data , according to status Fields are sorted in ascending order
-- The following two SQL Statements are equivalent ,
-- because order by Sort in ascending order by default
-- among ,ASC Keywords represent ascending sorting
-- select * from users order by status
select * from users order by status asc
- ORDER BY Clause – null
Yes users Table data , according to id Fields are sorted in descending order
-- desc Represents a descending sort
select * from users order by status desc
8.ORDER BY Clause – Multiple sort
- Yes users Table data , First according to status Fields are sorted in descending order , Again according to username In alphabetical order , Sort in ascending order
- Case code
select * from users order by status desc, username asc
9.id Uniqueness
- After inserting data , Find data id There is an interval
- There was before , It was later deleted , So after adding data , Even if this id Have been deleted , This id Will not be occupied
边栏推荐
- saltstack部署lnmp
- This comprehensive understanding
- Henan college entrance examination vs Tianjin college entrance examination (2008-2021)
- Leetcode-9.Palindrome Numbber
- 开源漫画服务器Mango
- 【迅为干货】龙芯2k1000开发板opencv 测试
- Oracle prompt invalid number
- fatal: refusing to merge unrelated histories
- webserver
- Latex various arrows / arrows with text labels / variable length arrows
猜你喜欢

JVM from getting started to abandoning 1: memory model
![[Xunwei dry goods] opencv test of Godson 2k1000 development board](/img/94/312bb1f0d5e8d49506f659ad23cd3a.jpg)
[Xunwei dry goods] opencv test of Godson 2k1000 development board

Duality-Gated Mutual Condition Network for RGBT Tracking

Do you know what the quotation for it talent assignment service is? It is recommended that programmers also understand

Leetcode-141. Linked List Cycle

Redux learning (III) -- using Redux saga, writing middleware functions, and splitting reducer files

The difference between arrow function and ordinary function

QT script document translation (I)

Object. Specific implementation and difference between create() and new

Starting from scratch (IV) enemy aircraft flying out of the border disappear automatically
随机推荐
Starting from scratch (V) realize bullet positioning and animation
Shuttle inside and outside margins
socket. IO cross domain stepping pit
Simple integration of client go gin six list watch two (about the improvement of RS, pod and deployment)
Use of qscriptengine class
数学方法论的含义和研究意义
[matlab printed character recognition] OCR printed letter + number recognition [including source code 1861]
生物序列智能分析平台blog(1)
Illustration of JS implementation from insertion sort to binary insertion sort [with source code]
3.1 naming rules of test functions
Unity 全景漫游过程中使用AWSD控制镜头移动,EQ控制镜头升降,鼠标右键控制镜头旋转。
洛谷P1091合唱队形(最长上升子序列)
. Net C Foundation (6): namespace - scope with name
Leetcode hot topic 100 topic 6-10 solution
A highly controversial issue
Common modules of saltstack
Analysis of key points and difficulties of ES6 promise source code
Records how cookies are carried in cross domain requests
A promise with bare hands
Flutter 约束容器组件