1----查詢活動次數:
2---活動人數的查詢1-------------活動次數查詢
select * from
( select province,year,act_num ,act_people
from bdd_tmp_ci order by "year" desc limit 5) as a1
order by act_num desc;
3---select * from
( select province,year,act_num ,act_people
from bdd_tmp_ci order by "year" desc limit 5) as a1
order by act_people desc;
4---連表查詢:select province,year,act_num ,act_people
from bdd_tmp_ci order by act_num desc limit 5 ;
5---插入語句:select b.`province`,a.`act_num`,a.`province_code`,a.`act_people`,a.`year`
from test1 as a,test_code as b
where a.`province_code`=b.`province_code`;
6---insert into author (id,username,password,email,bio)
values (#,#,#,#,#)
7---連表查詢:left joinselect * from bdd_tmp_ci where
"year"=(select max(year) as aaa from bdd_tmp_ci)
order by act_people desc limit 5;
8--將兩張表放到一塊顯示:兩張表中的屬性一致,直接在表中進行疊加進行顯示;select bra_lib_cod,user_num,province as bra_lib from (select bra_lib_cod,sum(user_num) as user_num from bdd_show_luri_usinf bdduse group by bra_lib_cod ) as a
left join procince_code on a.bra_lib_cod=procince_code.province_code
order by user_num desc limit 5;
select * from t1 union all select * from t2
SQL語句集錦
use tablename 要操作的資料庫名 select logicalfilename tablename log 日誌檔名 maxminutes 10,limit on time allowed to wrap log.newsize 1 你想設定的日誌檔案的大小 m setup initia...
常見sql語句集錦
1.unix timestamp 自 1970 01 01 00 00 00 的到當前時間的秒數差 2.select unix timestamp 2012 06 08 獲取date 日期的時間戳 3.select if unix timestamp 1000 createtime select t...
pgsql的sql語句時間條件轉換
postgresql資料庫,寫sql語句時涉及到根據時間查詢的條件,需要把表中字段的時間轉化成年 年月或者年月日。第一種 把時間欄位都轉化成字串型別來比較 to char table time,yyyy between and startyear endyear為查詢條件,string型別 第二種 ...