SQL的基礎查詢

2021-10-20 19:50:00 字數 1388 閱讀 8098

select

*from 表名

select

(列名……)

from 表名

select

(列名……)

from 表名

where 列名=

'值'--查詢所有符合條件的資訊

-- 可以使用關係運算子進行查詢

select 列名 as 別名,列名 as 別名 ……

from 表名

示列
select sname as 姓名,sage as 年齡, *** as 性別

from stu

select 列名a as 別名,列名b as a+b as別名

from 表名

select 列名 as 別名,別名=列名

from 表名

where 列名 is

null

示列
select studentname as 姓名,郵箱=email

from student

where email is

null

select 列名 as 別名,別名=列名

from 表名

where 列名 is

notnull

示列
select studentname as 姓名,郵箱=email

from student

where email is

notnull

select sname as 別名,

'值'as 別名

from 表名

示列
select sname as 姓名,

'北京'

as 位址

from stu

select

top num *

from stu

示列
select

top5

*from stu

可以使用百分比,向下取整
select

top20

percent

*from stu

示列
select

top5

*from stu

可以使用百分比,向下取整
select

top20

percent

*from stu

sql基礎查詢

1.查詢 northwind 資料庫employees 表中名以 a開頭的雇員的姓名。use northwind goselect firstname,lastname from employees where firstname like a go 2.使用演示指令碼建立表 插入資料,查詢以 x ...

sql基礎 sql連線查詢

這兩天在專案中寫連線查詢的時候突然回憶了一下各種連線查詢的語法 結果等,發現自己出了經常用的left join on 和等值連線以外其他的都不是很確定,於是乎就看看了相關的資料便有了這篇博文。sql 92標準所定義的from子句的連線語法格式為 fromjoin tablejoin typejoin...

SQL學習 查詢基礎

簡單查詢 1 查詢表的全部行和列 例1 select user qq,user name,user from users 例2 select from users 2 查詢表的部分列 例 select user qq from users 3 使用別名 例 select user qq as 玩家q...