中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

賣產(chǎn)品怎么做網(wǎng)站專業(yè)seo站長工具全面查詢網(wǎng)站

賣產(chǎn)品怎么做網(wǎng)站,專業(yè)seo站長工具全面查詢網(wǎng)站,網(wǎng)站建設(shè)中中文模板下載,晉城企業(yè)網(wǎng)站建設(shè)公司目錄 1 基本查詢 1.1 查詢相關(guān)列 (select * / 列名) 1.2 別名 (as) 1.3 去重 (distinct) 1.4 對列中的數(shù)據(jù)進(jìn)行運(yùn)算 (、-、*、/) 2 條件查詢 (where) 2.1 等值查詢 () 2.2 非等值查詢 (>、<、>、<、!、><) 2.3 邏輯判斷 (and、or、not) 2.4 區(qū)間判…

目錄

1 基本查詢

1.1 查詢相關(guān)列 (select * / 列名)

1.2 別名 (as)

1.3 去重 (distinct)

1.4?對列中的數(shù)據(jù)進(jìn)行運(yùn)算 (+、-、*、/)

2 條件查詢 (where)

2.1 等值查詢 (=)

2.2?非等值查詢 (>、<、>=、<=、!=、><)

2.3?邏輯判斷 (and、or、not)

2.4?區(qū)間判斷 (between and)

2.5?NULL 值判斷 (is null、is not null)

2.6?in 運(yùn)算符

2.7?模糊查詢 (like)

3 分支查詢

4 排序 (order by)

5 日期和時間函數(shù)


1 基本查詢

goods 表

drop table if exists goods;
create table goods (
id int(10) primary key auto_increment,
name varchar(14),
netprice float(7,2),
saleprice float(7,2),
weight float(7,2),
stockdate date
)charset=utf8; #單條插入
insert into goods(name,netprice, saleprice, weight, stockdate) values('香蕉', 2.5, 3.8, 24, '2024-02-13');#多條插入
insert into goods(name,netprice, saleprice, weight, stockdate) values
('蘋果', 4.5, 7.2, 15, '2024-02-12'),
('蘋果', 4.5, 7.5, 65, '2024-02-14'),
('橘子', 3.2, 4.5, 52, str_to_date('02-12-2024', '%m-%d-%Y')),
('橘子', 2.8, 4.5, 76, '2024-02-13'),
('橘子', 3.1, 5.2, 63, '2024-02-14'),
('葡萄', 2.1, 4.7, 26, str_to_date('2024/02/14', '%Y/%m/%d'));

1.1 查詢相關(guān)列 (select * / 列名)

生產(chǎn)環(huán)境下,優(yōu)先使用列名查詢。* 的方式雖然看起來便捷,但實(shí)際上需要轉(zhuǎn)換成全列名,效率低,可讀性差

select * from goods;
select id, name, stockdate from goods;

???

關(guān)鍵字順序

select

? ? ? ? ...

from

? ? ? ? ...

以上語句執(zhí)行順序:

  1. from
  2. select

1.2 別名 (as)

?通過 as 可以對列名取別名,as 可以省略(列名和別名之間用空格隔開)

select id as '商品id', name as '商品名', netprice '進(jìn)價', saleprice '售價' from goods;

1.3 去重 (distinct)

?通過 distinct 將查詢結(jié)果中的重復(fù)行去除

select name from goods;
select distinct name from goods;

?

1.4?對列中的數(shù)據(jù)進(jìn)行運(yùn)算 (+、-、*、/)

?可以對列中的數(shù)據(jù)進(jìn)行加 +、減 -、乘 *、除 /

select id '商品id', name '商品名', (saleprice - netprice) * weight as '利潤' from goods; 

2 條件查詢 (where)

通過 where 進(jìn)行條件查詢

關(guān)鍵字順序

select

? ? ? ? ...

from

? ? ? ? ...

where

? ? ? ? ...

以上語句執(zhí)行順序:

  1. from
  2. where
  3. select

2.1 等值查詢 (=)

select * from goods where name = '蘋果';

2.2?非等值查詢 (>、<、>=、<=、!=、><)

# 從商品中選擇 weight > 52 的商品
select id, name, netprice, saleprice, weight from goods where weight > 52;# 從商品中選擇 weight < 52 的商品
select id, name, netprice, saleprice, weight from goods where weight < 52;# 從商品中選擇 weight >= 52 的商品
select id, name, netprice, saleprice, weight from goods where weight >= 52;# 從商品中選擇 weight <= 52 的商品
select id, name, netprice, saleprice, weight from goods where weight <= 52;# 從商品中選擇 weight != 52 的商品,此外 != 還可以這樣用,如 name != '蘋果'
select id, name, netprice, saleprice, weight from goods where weight != 52;# 從商品中選擇 weight <> 52 的商品,<> 等價于 !=
select id, name, netprice, saleprice, weight from goods where weight <> 52;

?

2.3?邏輯判斷 (and、or、not)

# 選擇 weight > 52 且 name != '蘋果' 的商品
select id, name, netprice, saleprice, weight from goods where weight > 52 and name != '蘋果';# 選擇 weight > 52 或 not name = '蘋果' 的商品(not name = '蘋果' 等價于 name != '蘋果')
select id, name, netprice, saleprice, weight from goods where weight > 52 or not name = '蘋果';

2.4?區(qū)間判斷 (between and)

# 選擇 24 <=  weight <= 50 的商品
select id, name, netprice, saleprice, weight from goods where weight between 24 and 50;

2.5?NULL 值判斷 (is null、is not null)

# 查詢表 goods 中 weight 為 null 的商品
select * from goods where weight is null;# 查詢表 goods 中 weight 不為 null 的商品
select * from goods where weight is not null;

2.6?in 運(yùn)算符

  • in 運(yùn)算符語法:
    • where 列名 in (value1, value2, ...)
    • where 列名 not in?(value1, value2, ...)
    • 只要列值在列表項(xiàng) (value1, value2, ...) 中,則該行符合條件
  • in 列表項(xiàng)不僅支持?jǐn)?shù)字,也支持字符甚至?xí)r間日期類型等,并且可以將這些不同類型的數(shù)據(jù)項(xiàng)混合排列而無須跟 column(列) 的類型保持一致,如 in (1, 2,'str')
  • in 可以和 and、or、>、<= 等運(yùn)算符結(jié)合使用
  • in 列表項(xiàng)可以是子查詢
  • 如果 in?的列表項(xiàng)是確定的,那么可以用多個 or?來代替。一般認(rèn)為,如果是對索引字段進(jìn)行操作,使用 or?效率高于 in,但對于列表項(xiàng)不確定的時候(如需要子查詢得到結(jié)果),就必須使用 in?運(yùn)算符。另外,對于子查詢表數(shù)據(jù)小于主查詢的時候,也是適用 in?運(yùn)算符的
select id, name, netprice, saleprice from goods where name in ('蘋果', '香蕉');

2.7?模糊查詢 (like)

  • “_” 表示單個任意字符
  • “%” 表示任意個任意字符( 0 ~ n 個任意字符)
# 查詢表 goods 中 stockdate 為 '2024-02-x4' 的商品
select id, name, stockdate from goods where stockdate like '2024-02-_4';# 查詢表 goods 中 saleprice 為 7.xx 的商品
select id, name, saleprice from goods where saleprice like '7.%';# 查詢表 goods 中 name 不為 '蘋x' 的商品
select id, name stockdate from goods where name not like '蘋_';

3 分支查詢

分支查詢語法:

case

? ? ? ? when 條件1 then 結(jié)果1

? ? ? ? when 條件2 then 結(jié)果2

? ? ? ? ...

? ? ? ? else 結(jié)果n

end

select id, name, stockdate,casewhen stockdate = '2024-02-12' then '前天'when stockdate = '2024-02-13' then '昨天'when stockdate = '2024-02-14' then '今天'else '不知道'end as time
from goods;

4 排序 (order by)

order by 列名 asc?/ desc;

asc 表示升序,desc 表示降序,默認(rèn)是升序

關(guān)鍵字順序

select

? ? ? ? ...

from

? ? ? ? ...

where

? ? ? ? ...

order by

? ? ? ? ...

以上語句執(zhí)行順序:

  1. from
  2. where
  3. select
  4. order by
# 按照 weight 重量升序
select id, name, netprice, saleprice, weight from goods order by weight;
# 按照 weight 重量降序
select id, name, netprice, saleprice, weight from goods order by weight desc;
先按照 netprice 進(jìn)價降序,如果 netprice 相等,則按照 id 降序
select id, name, netprice, saleprice, weight from goods order by netprice desc, id asc;

5 日期和時間函數(shù)

時間函數(shù)描述
sysdate()獲得當(dāng)前系統(tǒng)時間(年、月、日、時、分、秒)
curdate()獲得當(dāng)前日期
curtime()獲得當(dāng)前時間
week(date)獲得指定日期是一年中的第幾周
year(date)獲得指定日期的年份
month(date)獲得指定日期的月份
day(date)獲得指定日期是月份的第幾天
hour(date)獲得指定時間的小時值
minute(date)獲得指定時間的分鐘值
second(date)獲得指定時間的秒值
datediff(enddate,startdate)

獲得兩個時間相隔的天數(shù) enddate - startdate

注意和 SQL Server 中的 datediff(datepart,startdate,enddate) 不同

adddate(date,n)在指定日期后面加 n 天
str_to_date(str,fmt)將不同時間格式的字符串轉(zhuǎn)為的特定格式的日期? ('%Y-%m-%d')
date_format(date,fmt)將時間轉(zhuǎn)為不同時間格式的字符串

時間格式描述
%Y年,4 位
%y年,2 位
%X年,其中的星期日是周的第一天,4 位,與 %V 使用
%x年,其中的星期一是周的第一天,4 位,與 %v 使用
%b縮寫月名
%c

月,數(shù)值

%M月名
%m

月,數(shù)值(00-12)

%j年的天 (001-366)
%D帶有英文前綴的月中的天
%d月的天,數(shù)值(00-31)
%e

月的天,數(shù)值(0-31)

%U周 (00-53) ,星期日是一周的第一天
%u周 (00-53) ,星期一是一周的第一天
%V周 (01-53) ,星期日是一周的第一天,與 %X 使用
%v

周 (01-53) ,星期一是一周的第一天,與 %x 使用

%w

周的天 (0=星期日, 6=星期六)

%a縮寫星期名
%W星期名
%T

時間,24-小時 (hh:mm:ss)

%r

時間,12-小時(hh:mm:ss AM 或 PM)

%pAM 或 PM
%H小時 (00-23)
%h小時 (01-12)
%I小時 (01-12)
%k小時 (0-23)
%l小時 (1-12)
%i分鐘,數(shù)值(00-59)
%S秒(00-59)
%s秒(00-59)
%f微秒
# 獲得當(dāng)前系統(tǒng)時間、當(dāng)前日期、當(dāng)前時間
select sysdate(), curdate(), curtime();# 獲得指定日期是一年中的第幾周、指定日期的年份、月份、指定日期是月份的第幾天
select week('2024-02-14') week, year('2024-02-14') year, month('2024-02-14') month, day('2024-02-14') day;# 獲得指定時間的小時值、分鐘值、秒值
select hour('16:33:24'),minute('16:33:24'), second('16:33:24');# 獲得兩個時間之間相隔的天數(shù),只計算日期,這里是2024-03-02 減去 2024-02-29 得到兩天
select datediff('2024-03-02 08:00:00','2024-02-29 10:00:00') day;# 將不同時間格式的字符串轉(zhuǎn)為的特定格式的日期
select str_to_date('2024/02-13 13:4356','%Y/%m-%d %H:%i%s');# 將時間轉(zhuǎn)為不同時間格式的字符串
select date_format(sysdate(), '%Y/%m/%d %H:%i:%s');# 在 '2024-02-28 23:59:59' 加 1 / 2 天
select adddate('2024-02-28 23:59:59',1);
select adddate('2024-02-28 23:59:59',2);

http://www.risenshineclean.com/news/27239.html

相關(guān)文章:

  • dede做網(wǎng)站地圖揚(yáng)州百度推廣公司
  • 網(wǎng)站建設(shè)專業(yè)團(tuán)隊(duì)軟文廣告例子
  • 圓通我做網(wǎng)站拉今日小說百度搜索風(fēng)云榜
  • 企業(yè)網(wǎng)站策劃書下載自媒體平臺注冊
  • 時時彩 網(wǎng)站開發(fā)seo咨詢河北
  • 無錫高端網(wǎng)站建設(shè)營銷文案
  • 順德做pc端網(wǎng)站鄭州seo外包顧問熱狗
  • 宜興做網(wǎng)站公司營銷軟文怎么寫
  • 海曙網(wǎng)站制作職業(yè)培訓(xùn)學(xué)校加盟
  • 中小企業(yè)的網(wǎng)站建設(shè)seo怎么學(xué)
  • 企業(yè)對電子商務(wù)網(wǎng)站的建設(shè)百度官方網(wǎng)站網(wǎng)址是多少
  • 東莞大嶺山鎮(zhèn)網(wǎng)站建設(shè)新聞式軟文
  • 自己開網(wǎng)站工作室阿里云域名查詢和注冊
  • 企業(yè)網(wǎng)站的缺點(diǎn)有域名了怎么建立網(wǎng)站
  • 大連網(wǎng)站推廣招聘手機(jī)優(yōu)化大師為什么扣錢
  • 昆山做網(wǎng)站的jofuns市場營銷一般在哪上班
  • 純靜態(tài)網(wǎng)站部署服務(wù)器跨界營銷案例
  • 優(yōu)秀網(wǎng)站設(shè)計效果圖企業(yè)營銷推廣怎么做
  • 格力網(wǎng)站建設(shè)首頁友情鏈接交換的作用在于
  • 廣東網(wǎng)站建設(shè)便捷抖音seo優(yōu)化
  • 哪些網(wǎng)站可以接單做推廣搜索引擎
  • 網(wǎng)站建設(shè)客服電話怎么找百度seo刷排名工具
  • 水電維修在哪個網(wǎng)站上做推廣好些系統(tǒng)優(yōu)化軟件
  • 怎么建個自己的網(wǎng)站seo建站收費(fèi)地震
  • 網(wǎng)站建設(shè)資訊平臺關(guān)鍵詞權(quán)重查詢
  • 達(dá)州做網(wǎng)站的公司b站引流推廣
  • 網(wǎng)站后臺添加投票系統(tǒng)電子商務(wù)網(wǎng)站建設(shè)方案
  • 做網(wǎng)站不會P圖怎么辦seo詞庫排行
  • 游戲ui設(shè)計落實(shí)20條優(yōu)化措施
  • 網(wǎng)站建設(shè)硬件網(wǎng)站怎么優(yōu)化推廣