㈠ 用sql语言编写查询语句
select s.sname,p.pname from s,p where s.city=p.city
这样就可以了
㈡ SQL语言编写怎么编
一、
1,select * from 学生 where 学生号 in (select 学生号 from 选课)
2, select * from 学生 where 学生号 in (select 学生号 from 选课 having count(课程号)=3)
3, select 选课.学生号,学生.姓名,课程.课程名 from 选课 ,学生,课程
where 选课.学生号=学生.学生号 and 选课.课程号=课程.课程号 group by 选课.学生号 ,选课.成绩 ;
4,select a1.课程号,a1.课程名,count(*) as 选课人数 from 课程 a1,选课 a2 where a1.课程号=a2.课程号 group by a1.课程号,a1.课程名
5,select * from 课程 where 课程号 in( select 课程号 from 选课 having count(学生号)>=5);
二、
1、select b2.商品代号,b1.单价,b1.数量,b2.产地 from 商品表1 b1,商品表2 b2 where b1.商品代号 = b2.商品代号
2、select distinct 产地 from 商品表2
3、select top 1 * from 商品表1 order by 数量 desc
㈢ 易语言SQL语句的查询、添加、删除和修改的代码应该怎么写
说明:几个简单的基本的sql语句
选择:select * from table1 where Id=1(Id=1为条件语句,根据自己情况自定义)
插入:insert into table1(field1,field2) values(value1,value2)
删除:delete from table1 where 范围
更新:update table1 set field1=value1 where 范围
查找:select * from table1 where field1 like ’%value1%’
㈣ 用sql语言编写程序
====SELECT
*FROM
za
SELECT
*FROM
zb
SELECT
za.
学号
,
za.姓名,
zb.分数
AS
Basic,
zb_1.分数
AS
C语言,
zb_2.分数
AS
数据库,
zb_3.分数
AS
Java,
(zb.分数
+
zb_1.分数
+
zb_2.分数
+
zb_3.分数)
/
4
AS
平均分FROM
za
INNER
JOIN
zb
ON
za.学号
=
zb.学号
INNER
JOIN
zb
AS
zb_1
ON
za.学号
=
zb_1.学号
INNER
JOIN
zb
AS
zb_3
ON
za.学号
=
zb_3.学号
INNER
JOIN
zb
AS
zb_2
ON
za.学号
=
zb_2.学号WHERE
(zb.课程
=
'BASIC')
AND
(zb_1.课程
=
'C语言')
AND
(zb_2.课程
=
'数据库')
AND
(zb_3.课程
=
'JAVA')====
==========除分数是INT外
其他全是
NVCHAR
㈤ sql语句该怎么写
1、
selectcar.numplateaslicense,COUNT(pet.petid)pet_countfrompet
leftjoinpersononperson.perid=pet.perid
leftjoincaronperson.perid=car.perid
groupbycar.numplate
2、
selectperson.sexgender,COUNT(person.perid)1t100000_countfromperson
whereincome<100000
3、
第三个题的答案粘贴文本删帖不了,附上图片。
㈥ 根据下述数据库编写SQL语言代码
1.
create table student
(Sno INT(10),
Sname CHAR(10),
Ssxe char(2),
Sage int(2)
Sdept char(50)
)
2.问题描述不清 我知道该怎么解答
3. update student set Sage=Sage+1
4.问题描述不清 我知道该怎么解答
5.insert into SC values('95020','1',null)
㈦ 用sql语句写出以下代码
select max(分数) as 最高分, min(分数) as 最低分, (max(分数)-min(分数)) as 二者之间的差距 from 表名 where 课程='701' group by 课程;
这样写试一下看看是否好用。
㈧ 用SQL怎么写一个生成随机的六位数
用SQL写一个生成随机的六位数代码如下:
declare @i int
set @i=0
while @i<1073
begin
update Actor set AtrPwd = RIGHT(100000000 + CONVERT(bigint,
ABS(CHECKSUM(NEWID()))), 6) --where aid=2
set @i=@i+1
end
㈨ 用sql语言编写 :这些语句应该如何编写
1
select 学号,系别编号 from 学生 where 年龄 between 19 and 21 and 性别='女'
2
select 学号,姓名 from 学生 where 系别编号 in ('d001','d002','d003')
3
select 姓名 from 学生 where 系别编号 is null
4
select 学号,成绩 from 成绩 order by 课程编号asc ,分数 desc
5
select 系别编号,count(*) as 人数 from 学生 group by 系别编号
6
select 学号,count(*) as 课程数 from 成绩 group by 学号 having count(成绩>80)>=2
7
select xh as 学号,kch as 课程号, cj as 成绩 from 成绩
㈩ 用sql语言实现下列功能的sql语句代码
1. 创建数据库 学生成绩数据库 代码
create database 库名
on primary
(
name='名字',
filename='物理存储路径',
size=5mb, 大小
filegrowth=10% 增长量
),
(
ndf文件 语法和MDF一样
)
log on
(
ldf文件 语法同上
)
2. 创建数据表 课程信息表 代码
课程信息表(课号char(6),名称)
要求使用:主键(课号),非空(名称)
use 数据库名
create table subjectInfo
(
subjectId char(6) constraint PK_subjectId primary key
subjectName varchar(20) not null
)
3.创建数据库 学生信息表 代码
学生信息表(学号char(6),姓名,性别,民族,身份证号)
要求使用:主键(学号),默认(民族),非空(民族。姓名),唯一(身份证号),检查(性别)
create table studentInfo
(
studentId char(6) constraint PK_studentID primary key
studentName varchar(20) not null
sex varchar(4) constraint CK_sex check(sex='男' or sex='女')
nation varchar(10) constraint DF_ default('汉族') not null
ID(突然忘记身份证号怎么拼了) varchar(30) constraint UQ_ID unique(id)
)
4.常见数据表 成绩信息表
成绩信息表(id,学号,课号,分数)
要求实用:外间(学号,课号),检查(分数),自动编号(id)
create table score
(
id int identity(1,1)
stuId char(6) constraint FK_stuID foreign key references studentInfo(studentID)
subjectID char(6) constraint FK_subjectID foreign key references subjectInfo(subjectId)
score int constraint CK_score check(score>0 and score<101)
)
5.将下列课程信息添加到课程信息表的代码
课号 名称
100101 西班牙语
100102 大学英语
修改 课号为100102的课程名称: 专业英语
删除 课号为100101的课程信息
insert subjectInfo values ('100101','西班牙语')
insert subjectInfo values ('100102','大学英语')
update subjectInfo set subjectName='专业英语' where subjectID='100102'
delete from subjectInfo where subjectID='100101'
6. 创建视图 成绩信息表视图 的代码
成绩信息表视图(学号,姓名,课号,课程名称,分数)
create view v_score
as
select 学号=studentInfo.studentID,姓名=studentInfo.studentName,课号=score.subjectId,课程名称=subjectInfo.subjectName,分数=score.score from score inner join studentInfo on score.stuID=studentInfo.studentId inner join subjectInfo on score.subjectId=subjectInfo.subjectID
累了 剩下几题待会来写