1)select sno, snmae, sex, age,addr from s
(2)select sname,sex,age from s where sex = '男' and age between 19 and 21
(3)insert into s (sno, snmae, sex, age,addr) values ('N10','姓名','男',21,'籍貫')
(4)delete from s where age >= 30
(5)delete from s where sname like '王%'
'
(6)update s set sname = '李鐵' where sname = '李四'
(7)update s set age = age + 1 where sex = '男'
(8)select sno, snmae, sex, age,addr from s order by age Desc
(9)select avg(age) as '平均年齡' where sex = '男'
(10)select sno,sname from s inner join sc on s.sno = sc.sno where sc.Cno = 'C2'
(11)create table s
(
sno varchar(5) primary key,
sname varchar(8),
sex varchar(2),
age int ,
addr varchar(10)
)
完全是按照你上邊的要求寫的, 希望能幫到你
『貳』 SQL性別限制只能寫男女,怎麼寫
create table 表名
(
sex char(2) check(sex='男' or sex='女')not null
)
默認性別為男的代碼如下:
create table 學生表
(
學號 char(5) not null primary key,
姓名 varchar(10) not null,
性別 char(2) default '男' check (性別 in ('男','女')) //其中default '男' 就是默認性別為男。
)
(2)sql語言怎麼加男朋友擴展閱讀:
使用其他方法限制性別只能寫男或女:
ALTERTALBE[表名]
ADDCONSTRAINT約束名CHECK(列名in('男','女'))not null
注意:CHECK 約束可以應用於一個或者多個列,也可以將多個CHECK 約束應用於一個列。
當除去某個表時,對這個表的CHECK 約束也將同時被去除。
參考資料:網路-check約束
『叄』 SQL語言怎麼查詢未婚的人
看看記錄中有沒有表示婚否的欄位,加上where條件判斷欄位就好了。
『肆』 性別只為男和女並且默認為男,SQL語句怎麼寫
樓上說的答非所問啊,人家是建表,你給個查詢出來
比如建立個學生表,里邊包括,學號,姓名,性別,其他欄位略
create table 學生表
(
學號 char(5) not null primary key,
姓名 varchar(10) not null,
性別 char(2) default '男' check (性別 in ('男','女'))
)
其中default '男'
就是默認為男
check (性別 in ('男','女')
就是性別只可以為男或女
『伍』 SQL語句怎麼設置性別只為男或女
給欄位設置check約束
例如:alter table test add constraints chk_Person CHECK (性別='男' or 性別='女')
『陸』 男女選項如何添加到資料庫.如何寫語言。添加在哪
資料庫中建一個欄位來記錄比如:SexFlag int類型 其中1表示男、2表示女
在界面上放兩個RadioButton分別為RadioButton1、RadioButton2分別為你的兩個可選按鈕;
在保存的時候做一個判斷,如果RadioButton1選中的話則欄位SexFlag 的值為1如果RadioButton2選中的話則為2;
至於修改的時候則分別設置RadioButton1與RadioButton2的Checked屬性就可以了,如果要選中則為True否則為False;
順便問一下,你有的是什麼語言寫程式呢?
『柒』 SQL語句!!按下面要求寫語句! 在線等待!
select Sno as' 學號' Sname as '姓名' Sex as' 性別' Sage as '年齡' Sdept as '院系' from student
加sql的判斷 如if(性別.eques('男'))。。。。
if(性別.eques('女'))。。。。
else
。。。。
在查詢一次顯示,最好自己寫存儲過程
『捌』 以下問題用SQL語言怎麼輸入
1)輸出「學生」表中的所有信息。
select*from學生
2)輸出「學生」表中的所有信息,要求只顯示學號和姓名欄位。
select學號,姓名from學生
3)輸出「學生」表中所有男生信息,要求顯示學號、姓名、性別字
段。
select學號,姓名,性別from學生where性別='男'
4)輸出「學生」表中學號為「03201017」的學生信息。
select*from學生where學號='03201017'
5)輸出「學生」表中學號為「03101010」的學生成績,要求顯示學
號、姓名、課程名、成績欄位。
selecta.學號,b.姓名,c.課程名稱,a.成績
from修課成績a,學生b,課程c
wherea.學號=b.學號anda.課程代碼=c.課程代碼
anda.學號='03101010'
後續的還在寫
『玖』 簡單的SQL語言怎麼寫
1.select * from tablename;
2.selct 選修課程 from tablename;
3.select 姓名 from tablename where 年齡<21;
4.select 年齡 from tablename where 姓名 like "張%";
5.select * from tablename order by 年齡;