sql查詢語句怎麼寫,sql彙總查詢的語句怎麼寫啊

2022-03-05 22:49:12 字數 4457 閱讀 1529

1樓:匿名使用者

如果表裡只是那幾列資料的話

select a.欄位名,b.欄位名

from 表 as a

left join

表 as b

on a.substring(欄位名,7,2)=b..substring(欄位名,7,2)

where a.欄位名 like '201008%' and b.欄位名 like '201009%'

2樓:鳳凰熊

你的結果有問題吧。怎麼是2020了??

3樓:匿名使用者

lz 你這個也說得太不明確了吧。 表的名字是什麼?20100901是什麼?結果是新增一列20100801資料,並刪除原來的相關資料,還是另建立一個表?這些都沒說清楚呀。

select * from table where xx=yy;查詢語句

insert into table values(xx,yy,zz,....);插入語句

delete from table where xx=yy;刪除語句

基本上就是這些語句的組合了。

還有就是creat table() values();建立表

可以參考:

如何用sql語句實現查詢名字

4樓:

可以用sql的模糊查詢。語句如下

select * from 表名 where 欄位 like '%關鍵字%'

其中 % 為萬用字元。

條件的意思就是查詢欄位裡面帶「關鍵字」的資料。

5樓:

假設表叫【tab_1】

該表的「姓名」欄位是【name】

假設你要查的這個人的姓是【張】

select * from tab_1 where name like '張%';

「%」是萬用字元,類似於windows檔案搜尋中的萬用字元「*」

上面sql的意思是,搜尋tab_1表中,所有姓張的人員資訊返回值可能是:

name`````…………

-------------------------張三`````…………

張小薇```…………

張伯倫```…………

張可`````…………

假設知道這個人的名(例如:什麼小田),不知道姓,就這樣查:

select * from tab_1 where name like '%小田';

6樓:

select * from tablename where 姓名 like '周%'

周就是姓

sql彙總查詢的語句怎麼寫啊

7樓:

select department 部門,id 工號,name 姓名,sum(money) 金額

from 表

where month(date)=4

group by department,id,name

8樓:xingting的故事

select id, name , count(money) from 表名 where month(date) ='2' group by id ;

9樓:匿名使用者

select department,id,name,sum(money) from 表名 where dd>=#2013-4-01# and dd<#2013-5-01# group by department,id,name

sql查詢語句如何寫 100

sql查詢語句怎麼寫,高分**等

10樓:匿名使用者

1、select * from bpass where upass like '%123%' or uemail like '%123%' or ufrom like '%123%'

2、select *  from dbpass where upass= '123456' or uemail='123456' or ufrom='123456'

3、讀取出欄位資料來判斷吧。下面是asp寫法

set rs="select *  from dbpass where upass= '123456' or uemail='123456' or ufrom='123456'"

if rs("upass")="123456" then response.wirte "表在upass"

if rs("uemail")="123456" then response.wirte "表在uemail"

if rs("ufrom ")="123456" then response.wirte "表在ufrom "

11樓:匿名使用者

select * from dbpass where upass like '%123%'

select * from dbpass where upass='123456'

看來你對sql的語法不太瞭解啊。。。

sql語句查詢同一欄位滿足多個值如何寫呢?

12樓:匿名使用者

查詢得到的資料需要如下老公 lg年齡 lg月薪 老婆 lp年齡 lp月薪 合計年齡 合計工資張某 27 500 李某 26 800 53 1300 select 老公,a.年齡 as lg

13樓:

可以、select * from tel where phone in('0773','0775') order by num desc

14樓:明明加油吧白羊

select * from tel where phone =0773 or phone=0775 order by num desc

mysql多表查詢sql語句怎麼寫?

15樓:sky不用太多

一使用select子句進行多表查詢

select 欄位名 from 表1,表2 … where 表1.欄位 = 表2.欄位 and 其它查詢條件

select a.id,a.name,a.

address,a.date,b.math,b.

english,b.chinese from tb_demo065_tel as b,tb_demo065 as a where a.id=b.

id注:在上面的的**中,以兩張表的id欄位資訊相同作為條件建立兩表關聯,但在實際開發中不應該這樣使用,最好用主外來鍵約束來實現

二使用表的別名進行多表查詢

如:select a.id,a.

name,a.address,b.math,b.

english,b.chinese from tb_demo065  a,tb_demo065_tel  b where a.id=b.

id and b.id='$_post[textid]'

sql語言中,可以通過兩種方式為表指定別名

mysql是一個關係型資料庫管理系統,由瑞典mysql ab 公司開發,目前屬於 oracle 旗下產品。mysql 是最流行的關係型資料庫管理系統之一,在 web 應用方面,mysql是最好的 rdbms (relational database management system,關聯式資料庫管理系統) 應用軟體。

mysql是一種關聯式資料庫管理系統,關聯式資料庫將資料儲存在不同的表中,而不是將所有資料放在一個大倉庫內,這樣就增加了速度並提高了靈活性。

mysql所使用的 sql 語言是用於訪問資料庫的最常用標準化語言。mysql 軟體採用了雙授權政策,分為社群版和商業版,由於其體積小、速度快、總體擁有成本低,尤其是開放原始碼這一特點,一般中小型**的開發都選擇 mysql 作為**資料庫。

由於其社群版的效能卓越,搭配 php 和 apache 可組成良好的開發環境。

包含and又包含or的sql查詢語句怎麼寫?

16樓:匿名使用者

or的優先性大於and,所以你的sql語句條件就為:

([index_push]<>1 and title like '%深圳%') or (title like '%北京%')

條件改成

[index_push]<>1 and (title like '%深圳%' or title like '%北京%')

17樓:匿名使用者

select * from [article]where [index_push]<>1 and(title like '%深圳%' or title like '%北京%')

order by [id] desc

sql查詢語句

你寫的就已經是對的了啊。你還要問什麼呢?select a.b.from a b where a.id b.id 就這個啊。從a,b表取全部的資料,他們的id是關聯條件。比如a表 暫且定為學生表 b表,為成績表。一個學生id對應一個或多個成績。所以關聯條件是學生id。當然。在b表中必定存有學生id。不...

sql年度按照每個月彙總查詢原語句

select to char aa.jiuzhenrq,mm 月 as 月份,count aa.jiuzhenid as 門診人次 from zj jiuzhenxx aa,gy bingrenxx bbwhere aa.yuanquid 4and aa.bingrenid bb.bingrenid...

sql查詢語句的特殊符號,SQL查詢語句的特殊符號

這是最基本的查詢語句,就是從 product 表查詢 id product name product images 這4個欄位,條件是 product images 不等於空,查詢結果按照 product order id 的升序排列 從product表中查詢符合product images這個欄位...