create database if not exists school default charset=utf8;
use school;
create table if not exists studentinfo(
id int primary key auto_increment,
`name` varchar(20),
sex char,
age int,
address varchar(100)
);
show tables;
insert into studentinfo(`name`,sex,age,address)values("賈寶玉","男",18,"北平"),
("賈政","男",40,"浙江"),("晴雯","女",20,"四川"),("襲人","女",29,"貴州"),
("薛寶釵","女",19,"北平"),("林黛玉","女",17,"浙江");
-- 查看數(shù)據 通配符*表示所有
select * from studentinfo;
-- 手動寫出字段 全量查詢
select id, `name`, sex, age, address from studentinfo;
-- 只查詢指定的數(shù)據列
select id, `name`, sex from studentinfo;
-- 條件查詢
select * from studentinfo where sex='女';
-- 根據查詢結果排序 order by
select * from studentinfo order by age desc;
select * from studentinfo order by age desc,id desc;
-- 顯示查詢結果的條數(shù)
select * from studentinfo limit 3 ;
-- 顯示查詢結果中從索引為5開始的往后3條數(shù)據
select * from studentinfo limit 5,3;
-- 復合
select * from studentinfo where sex='女' order by age desc limit 3;
-- 別名AS as 可以省略
select id as 編號, `name` as 姓名, sex as 性別, age as 年齡, address as 地址 from studentinfo;
-- 單條件查詢
select * from studentinfo where age<20;
select * from studentinfo where age is not null;
-- 多條件查詢
-- 不等于
select * from studentinfo where age!=20;
select * from studentinfo where age<>20;
select * from studentinfo where not (age=20);
-- 與 或
select * from studentinfo where age>20&& sex='女';
select * from studentinfo where age>20 and sex='女';
select * from studentinfo where age>20 || sex='女';
select * from studentinfo where age>20 or sex='女';
-- distinct 去除重復的數(shù)據
select distinct `name`, sex, age, address from studentinfo;
數(shù)據查詢入口
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
- 文/潘曉璐 我一進店門九杂,熙熙樓的掌柜王于貴愁眉苦臉地迎上來颁湖,“玉大人,你說我怎么就攤上這事例隆∩啵” “怎么了?”我有些...
- 正文 為了忘掉前任屋休,我火速辦了婚禮,結果婚禮上备韧,老公的妹妹穿的比我還像新娘劫樟。我一直安慰自己,他們只是感情好织堂,可當我...
- 文/花漫 我一把揭開白布叠艳。 她就那樣靜靜地躺著,像睡著了一般易阳。 火紅的嫁衣襯著肌膚如雪附较。 梳的紋絲不亂的頭發(fā)上,一...
- 文/蒼蘭香墨 我猛地睜開眼扎酷,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了遏匆?” 一聲冷哼從身側響起法挨,我...
- 正文 年R本政府宣布侥涵,位于F島的核電站沼撕,受9級特大地震影響宋雏,放射性物質發(fā)生泄漏。R本人自食惡果不足惜端朵,卻給世界環(huán)境...
- 文/蒙蒙 一好芭、第九天 我趴在偏房一處隱蔽的房頂上張望燃箭。 院中可真熱鬧冲呢,春花似錦、人聲如沸招狸。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽裙戏。三九已至乘凸,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間累榜,已是汗流浹背营勤。 一陣腳步聲響...
推薦閱讀更多精彩內容
- 43所院校信息的歷年報考錄取數(shù)據查詢入口辨泳,點開網址可直接查看~ 1.南開大學 「2015年-2019年」 http...
- 獲取單個對象上面的例子中filter() 函數(shù)返回一個記錄集虱岂,這個記錄集是一個列表。相對列表來說菠红,有些時候我們更需...
- 在input輸入框輸入數(shù)字的時候第岖,會展示data.json里面的數(shù)據,當刪掉input輸入框輸入數(shù)字的時候试溯,隱藏出...
- 今天青石的票圈出鏡率最高的杠纵,莫過于張藝謀的新片終于定檔了。 一張滿溢著水墨風的海報一次次的出現(xiàn)在票圈里钩骇,也就是老謀...