当前位置:网站首页>C language and SQL Server database technology
C language and SQL Server database technology
2022-07-25 09:26:00 【yushang_ zhang】
Data query Foundation
One 、 Query basis
1. The purpose of storing data in a database is to query
2. Query is the most attractive aspect of database
3. The essence of query is data filtering
4.select: choice , lookup
5.select Statement is used to query , The grammar is as follows
select Name from Table name [where Conditions ] [order by Sort columns [asc / desc] ]6. Query all rows and all columns
select * from Student7. Query partial Columns
select stuName,stuAge from Student8. Alias the list
select stuName as full name stuAge as Age from Student
select stuName name ,stuAge age from Student --as It can be omitted
select stuName 'name' from Student -- You can use single quotation marks , Prevent special symbols or spaces 9. adopt where Some lines of condition query
select * from student where stuSex=' male '10. Multiconditional query
select * from student where stuSex=' male ' and stuAge > 22Two 、 Query basis
1. Query null value
select * from BookInfo where bookAuthor is null2. Use constant columns in queries
select stuName,stuAge,' Central Primary School ' as schoolName from Student3. Columns can be calculated or connected , Generate a new column
select bookPrice * bookCount as totalMoney from BookInfo
select bookDesc=bookName + '-' + bookAuthor from BookInfo4. Return the limited number of rows
a、select top 5 * from Student -- Return to the former 5 strip
b、select top 20 perent * from Student -- Return to the top percent 20 The data of 5. Sort
a、asc Expressing ascending order ,desc Representation of descending order
b、 The default is asc Ascending
c、 Use order by To specify the rank
d、 Between multiple rows , Comma separated
3、 ... and 、 Use functions in queries 1
1. Output statement
a、select
b、print
2. String function
charIndex("cd" , "abcdecdfg" , 4) --》 Return the position of the found string , From the beginning
len("abcd") --》 Find the string length
upper()/ lower() --》 Turn capitalization 、 Turn lowercase
ltrim()/ rtrim() --》 Remove the left side 、 Space on the right
right("abcdef",3) --》 Intercept a string of specified length from right to left
replace("abcdef","ab","xx") --》 Replace string
stuff("abcdef ",2,3,"xxx") --》 Delete the specified length string from the specified position , Reinsert content
3. Mathematical functions
rand() --》 Generate 0-1 Between random float value
abs(-43) --》 Find the absolute value
ceiling(43.5) --》 Rounding up
floor(43.5) --》 Rounding down
power(5,2) --》 Exponentiation
round(43.543,2) --》 Rounds a numeric expression to the specified precision
sign(-1) --》 For integers, return +1, A negative number returns -1,0 return 0, Judge whether the number is positive or negative
sqrt(9) --》 take a square root
Four 、 Use functions in queries 2
1. Date function
getDate() --》 Get system current time
dateAdd(mm,4,"1990-05-06") --》 Add the specified value to the specified part of the date
dateDiff(mm,"1990-05-01","1991-05-01") --》 Find the difference between two dates
dateName(dw,"1990-01-02") --》 The string form of the specified date part in the date
datePart(year,"1990-01-02") --》 The integer form of the specified date part of a date
2. Some parameters of date and their abbreviations
year(yy,yyyy) weckday(dw,w) hour(hh)
quart(qq,q) month(mm,m) minute(mi,n)
dayofyear(dy,y) second(ss,s) day(dd,d)
millisecond(ms) week(wk,ww) day(dd,d)
3. System function
convert(varchar(10),12345) --》 Data type conversion
current_user --》 Returns the current user name
dataLength(" I s") --》 Returns the number of bytes occupied by the expression
host_name() --》 Returns the current computer name
system_user --》 Return the current login
边栏推荐
- Difference between redis and mongodb (useful for interview)
- Jspdf generates PDF files. There is a problem of incomplete files. Files are downloaded in the background, but not in the foreground
- registration status: 204
- Go基础2
- activemq--异步投递
- jsPDF生成PDF文件,文件不全问题,后台进行文件下载,前台不下载
- 机器学习 —— Sklearn包中StandardScaler()、transform()、fit()的详细介绍
- Leetcode组合总和+剪枝
- Front page printing
- C#语言和SQL Server数据库技术
猜你喜欢
随机推荐
『每日一问』LockSupport怎么实现线程等待、唤醒
Click to hide the column in wechat applet, and then click to show it
[C language] dynamic memory management, flexible array
28. Slot
Idea hot deployment
Two Sum
Go基础1
分布式一致性协议之Raft
leetcode-238.除自身以外数组的乘积
什么是贫血模型和充血模型?
Floating point number exploration
activemq--延迟投递和定时投递
Programmers can't SQL? Ashes Engineer: all waiting to be eliminated! This is a must skill!
ActiveMQ -- AMQ of persistent mechanism
一文搞懂try、catch、finally(包含return)执行流程(全网最详细解析)
多态和接口
Difference between redis and mongodb (useful for interview)
uni-app - Refused to display ‘xxx‘ in a frame because an ancestor violates the following Content Sec
通过robocopy对文件/夹进行复制
『怎么用』装饰者模式

![[arm] Xintang nuc977 transplants wk2124 drive](/img/0c/fa21d7a44e0263dde4d3135a78818f.png)
![[HCTF 2018]admin](/img/d7/f0155c72d3fbddf0a8c1796a179a0f.png)






