(1).查詢出學生表中年齡為22或者24的學生資訊
select id,name,age,addres,birthday from stu where age=『22『 or age=『24『;
(2).查詢出學生表中位址不為上海和深圳的所有學生資訊
select id,name,age,addres,birthday from stu where addres!=『上海『 and addres!=『深圳『;
(3).查詢出學生表中位址不為北京,上海和深圳的所有學生資訊
select id,name,age,addres,birthday from stu where not addres in(『北京『,『上海『,『深圳『);
(4).查詢出學生表中年齡在22-26的所有學生資訊
select id,name,age,addres,birthday from stu where age>=『22『 and age<=『26『;
(5).查詢出學生表中生日在2023年出生的學生資訊
select id,name,age,addres,birthday from stu where birthday between『1993-01-01『and『1993-12-31『;
(6).查詢出學生表中生日為null的那個學生資訊
select id,name,age,addres,birthday from stu where birthday is null;
(7).查詢出學生表中生日不為nul的那些學生資訊
select id,name,age,addres,birthday from stu where birthday is not null;
(8).查詢出成績表中成績在60-80之間的所有記錄
select * from stu_score where score『60『;
(9).查詢出成績表中成績在70,80或90的所有記錄
select * from stu_score where score=『80『 or score=『70『 or score=『90『;
(10).查詢學生表中位址是北京或年齡小於22歲的學生記錄
select id,name,age,addres,birthday from stu where addres in(『北京『) or age
5.查詢結果的排序,指定查詢的行數
(1).以年齡降序列出學生表的所有資訊
select * from stu order by age desc;
(2).以stu_id公升序、成績降序列出成績表的所有記錄
select * from stu_score order by stu_id asc;
(3).找出從第4行起,往下查詢4行學生表資訊記錄
select * from stu limit 4,4;
(4).找出從第4行起,往下查詢15行記錄,沒15行,顯示以下的全部的學生表資訊
select * from stu limit 4,15;
(5).查詢出學生表中第5到第10行記錄。
select * from stu limit 4,6;
查詢截圖:
stu表
stu_score表
MySQ樹狀結構資料 遞迴查詢
for example create table products id int,name varchar 100 parent id int insert into products values 15,category15 0 not a descendant of 19 16,category...
PHP程式 mysql查詢顯示資料轉碼
php程式 mysql查詢顯示資料轉碼 1 mysql query set names utf8 將查詢資料轉碼為utf8,也就是轉換為utf 8 2 mysql query set names gbk 將查詢資料轉碼為gbk,如gbk2312 在寫資料庫連線檔案時,寫成 conn mysql co...
mysql資料連線查詢 mysql 資料查詢
連線查詢 1.連線 join 也稱 連線,從兩個關係的笛卡爾積中選擇屬性間滿足一定條件的元組。等值連線 為 的連線運算稱為等值連線。從關係r和s的廣義笛卡爾積中選取a b屬性值相等的元組。自然連線 一種特殊的等值連線。要求關係中進行比較的分量必須是同名的屬性組,並且在結果中把重複的屬性去掉。外連線 ...