sql spj

article/2025/9/27 0:37:31

select sno,snamevar
from student;

select sno,snamevar,sdeptvar
from student;

select *
from student;

select snamevar,2014-age
from student;

select snamevar,‘year of birth’,2014-age,lower(sdeptvar)
from student;

select snamevar
from student
where sdeptvar=‘1’;

select snamevar,age
from student
where age<20;

select all sno
from student;

select snamevar,sdeptvar,age
from student
where age between 20 and 30;

select snamevar,sdeptvar,age
from student
where age not between 20 and 30;

select snamevar,sex
from student
where sdeptvar not in (‘123’,‘1’,‘3’);

select *
from student
where sno like ‘8’;

select snamevar,sno,sex
from student
where sno=‘8’;

select snamevar,sno,sex
from student
where snamevar like’小_’;

select snamevar,sno,sex
from student
where snamevar like’_周’;

select snamevar,sno,sex
from student
where snamevar not like’_周’;

select cno,credit
from course
where cnamevar like’数据库’;

select *
from student
order by sdeptvar,age desc;

Market

select *
from Custemers

select *
from Custemers
where CITY=‘上海’;

use market;
create table Custemers (
CID char(10) not null unique,
CNAME varchar(20) not null,
ADDRESS varchar(20) not null,
CITY varchar(20) not null,
PHONE char(11) not null,
FIRM varchar(50) not null,
BIRTH date,
CTYPE varchar(20)
);
create table Goods(
GID char(10) not null unique,
GNAME varchar(20) not null,
PRIECE float not null,
DEPICT varchar(100),
NUM tinyint not null,
PROVIDE varchar(20) not null,
STATUS tinyint
);
create table Orders(
OID char(10) not null unique primary key,
GID char(10) not null,
CID char(10) not null,
NUM tinyint not null,
SUM float not null,
ODATE date not null,
foreign key(CID) references Custemers(CID),
foreign key(GID) references Goods(GID)
);
insert into Custemers(CID,CNAME,ADDRESS,CITY,PHONE,FIRM,BIRTH,CTYPE) value(1,‘小赵’,‘上海’,‘上海’,111111,‘国美’,‘1999.10.12’,1),
(2,‘小田’,‘西安’,‘西安’,222222,‘飞科’,‘1999.10.12’,2),(3,‘北京’,‘北京’,‘女’,333333,‘国美’,‘1999.10.12’,3),
(4,‘小李’,‘杭州’,‘杭州’,444444,‘国美’,‘1999.10.12’,‘computer’),(5,‘重庆’,‘重庆’,‘男’,555555,‘飞科’,‘1999.10.12’,23),
(6,‘小吴’,‘西安’,‘西安’,666666,‘飞科’,‘1999.10.12’,123),(7,‘重庆’,‘重庆’,‘男’,777777,‘国美’,‘1999.10.12’,123),
(8,‘小王’,‘上海’,‘上海’,888888,‘国美’,‘1999.10.12’,123),(9,‘西安’,‘西安’,‘男’,99999,‘飞科’,‘1999.10.12’,123);
insert into Goods(GID,GNAME,PRIECE,DEPICT,NUM,PROVIDE) value(1,‘computer’,‘5000’,‘computer’,100,‘国美’),
(2,‘手机’,‘4000’,‘phone’,100,‘国美’),(3,‘手机’,‘4000’,‘phone’,100,‘国美’),
(4,‘手机’,‘4000’,‘phone’,100,‘国美’),(5,‘glass’,‘4000’,‘眼镜’,100,‘国美’),
(6,‘手机’,‘4000’,‘phone’,100,‘国美’),(7,‘手机’,‘4000’,‘phone’,100,‘国美’),
(8,‘pencil’,‘4000’,‘笔’,100,‘国美’),(9,‘computer’,‘4000’,‘computer’,100,‘国美’);

select GID,GNAME,PRIECE
from Goods
where DEPICT=‘computer’;

select GID,GNAME,PRIECE
from Goods
where DEPICT=‘computer’;

select GNAME,NUM,PRIECE
from Goods
where NUM between 100 and 500;

select GNAME name,NUM,PRIECE*0.25 PRIECE,PRIECE
from Goods
where NUM between 100 and 500;

alter database jwgl default character set=utf8;
set sql_safe_updates=0;

找出所有供应商姓名和所在城市

use SPJ;
select Sname,City
from s

在这里插入图片描述

找出所有零件的名称,颜色,数量

SELECT Pname,Color,weight
from P

在这里插入图片描述

找出供应商s1所提供的零件的工程号码

SELECT jno from SPJ where Sno='S1'

在这里插入图片描述

找出工程项目J2 使用的各种零件的名称及数量在这里插入图片描述

select P.Pname,SPJ.Qty
from P,SPJ
where P.Pno=SPJ.Pno
and SPJ.Jno='J2';

找出上海厂商供应的所有零件的号码

select distinct Pno
from spj
where sno in
(select sno
from s
where city='上海') 

找出使用上海产的零件的工程名称

select Jname
from J,SPJ,S
where J.Jno=SPJ.Jno
and SPJ.Sno=S.Sno
and S.City='上海'

找出没有使用天津产的零件的工程号码

select Jno
from J
WHERE NOT EXISTS
(select *
from SPJ
where SPJ.JNO=J.JNO
and SNO IN(select SNOFROM SWHERE CITY='天津'))

在这里插入图片描述

把全部红色零件的颜色改成蓝色

updata P
set Color='蓝'
where Color='红'

由s5供给J4的零件,P6改为由S3供应 请做必要修改

update
SPJ
set Sno=‘S3’
where Sno=‘s5’
and Jno=‘J4’
and Jno=‘J6’

从供应商关系中 删除S2的记录 并从供应情况关系中删除相应记录
delete
from SPJ
where Sno=‘S2’;
delete
from S
where Sno=“S2”

请将(S2 ,J6,P4,200)插入供应情况关系
insert into SPJ(Sno,Pno,Jno,Qty)
values(“S2”,“P6”,“J4”,200)

use TSGL;
drop table S;
drop table p;
drop table j;
create table S(
SNO char(10) not null unique,
SNAME varchar(20) not null,
STATUS tinyint not null,
CITY varchar(10) not null
);
create table P(
PNO char(10) not null unique,
PNAME varchar(20) not null,
COLOR varchar(2) not null,
WEIGHT tinyint not null
);
create table J(
JNO char(10) not null unique,
JNAME varchar(20) not null,
CITY varchar(10) not null
);
create table SPJ(
SNO char(10) not null,
PNO char(10) not null,
JNO char(10) not null,
QTY tinyint not null,
primary key(SNO,PNO,JNO),
foreign key(SNO) references S(SNO),
foreign key(PNO) references P(PNO),
foreign key(JNO) references J(JNO)
);
insert into S(SNO,SNAME,STATUS,CITY) value(‘s1’,‘精益’,20,‘天津’),
(‘s2’,‘盛锡’,21,‘北京’),(‘s3’,‘东方红’,19,‘北京’),
(‘s4’,‘丰泰盛’,20,‘天津’),(‘s5’,‘为民’,20,‘上海’);


http://chatgpt.dhexx.cn/article/UGo47urq.shtml

相关文章

浅谈online judge平台 spj [special judge] 使用 | 修改问题

浅谈oj平台 spj 使用 | 修改问题 首先&#xff1a;参数对应返回值代码提交几种spj第一种&#xff1a;简单的一类特判第二种&#xff1a;多组输入的特判第三种&#xff1a;需要判断特殊情况[impossible]第四种&#xff1a;带有[testlib.h]的spj第五种&#xff1a;GCPC [German C…

HUSTOJ SPJ 示例

什么是 SPJ SPJ 是 Special Judge 的意思。 什么时候使用 SPJ 当题目答案不止一个的时候&#xff0c;我们就必须使用 SPJ。 如何使用 SPJ 题目中打开 SPJ 首先&#xff0c;我们需要在出题的时候&#xff0c;增加 SPJ 选项&#xff0c;如下图所示。 题目保存后&#xff0…

《数据库原理与运用》上机实验之SPJ

《数据库原理与运用》上机实验之SPJ 前言一、关系模式二、使用SQL语句创建、修改基本表1.对基本表字段名的增加2.对基本表字段名的增加3.索引 二、使用SQL语句对数据库表的单表查询1.对指定列的查询2.对表达式计算和改变表达方式的查询3.消除重复行的查询4.WHERE条件查询5.分组…

SPJ数据库查询

起始 SQL语句建表 建表 后续图示为在SQL Server Management Studio中快捷创建的&#xff0c;并不是代码创建的。 CREATE TABLE S ( SNO CHAR(2) UNIQUE, SNAME CHAR(6), STATUS CHAR(2), CITY CHAR(4));CREATE TABLE J (JNO CHAR(2), JNAME CHAR(8), CITY CHAR(4) ); CREATE …

二 DeepinV20版本安装

安装 https://www.deepin.org/zh/download/ 准备工作&#xff1a;一个U盘&#xff0c;4G就够&#xff1b;镜像包&#xff1b;老毛桃或是官网提供的启动工具。 分区规划&#xff1a;至少3个区&#xff0c; 一个挂 / &#xff08;建议至少10G&#xff09;, SWAP分区&#xff08…

Windows10+deepin双系统安装(选用意义,安装教程)

1.为什么选用deepin 为什么要选用deepin&#xff0c;想必能看到该篇文章&#xff0c;肯定知道deepin是linux系统&#xff0c;而linux系统的发行版众多&#xff0c;至于具体那些&#xff0c;又有什么区别&#xff0c;请读者参考https://blog.csdn.net/bernin/article/details/83…

Deepin安装NVIDIA显卡驱动

显卡驱动可以通过官方库安装&#xff0c;本文使用官方NVIDIA 驱动手动安装。 时间&#xff1a;2020.8 系统版本&#xff1a;Deepin v20 beta Nvidia驱动安装 1 下载驱动 进入NVIDIA官网下载Linux驱动&#xff1a;NVIDIA官网驱动下载 找到对应驱动后下载&#xff0c;记住下载位…

【系统 win10 deepin】双系统安装(win10和deepin双系统)

概述 所有的事情都源自于一只蝙蝠&#xff0c;在这个无聊且漫长的寒假&#xff0c;终于能够实现躺在家里也能为国家做出贡献的时候了。 既然闲着也是闲着&#xff0c;那为何不折腾一下自己的电脑呢。 相信很多猿在虚拟机里已经体验过linux系统&#xff0c;那么怎么在实体机上怎…

Deepin重装Win10

Deepin重装Win10 分享荣耀magicbook 8256 全盘安装deepin后&#xff0c;重装win10之旅。 如有需要请务必先看完再做&#xff01;&#xff01;&#xff01;会清除电脑硬盘上的全部数据&#xff01;&#xff01;&#xff01;请自行备份&#xff01;&#xff01; 重装win10系统我…

【Deepin】 Deepin 系统安装教程

安装过程 准备准备足够的磁盘空间下载格式化制作启动盘 安装设置U盘启动项根据引导安装新建分区 设置 记录一下第N次安装Deepin系统的过程。 准备 准备足够的磁盘空间 deepin用于生活日常的话&#xff0c;不需要太大的空间。我准备了40G左右的空间&#xff08;很小&#xff0…

国产操作系统Deepin的安装

一、简介 武汉深之度科技有限公司&#xff08;以下简称深度科技&#xff09;成立于 2011 年&#xff0c;是专注基于 Linux 的国产操作系统研发与服务的商业公司。 作为国内顶尖的操作系统研发团队&#xff0c;深度科技以提供安全可靠、美观易用的国产操作系统与开源解决方案为…

国产操作系统之深度deepin安装

一、深度deepin简介 Deepin(原名Linux Deepin)致力于为全球用户提供美观易用&#xff0c;安全可靠的Linux发行版。deepin项目于2008年发起&#xff0c;并在2009年发布了以linux deepin为名称的第一个版本。2014年4月更名为Deepin&#xff0c;在中国常被称为“深度操作系统“。深…

Deepin 20版 安装教程(Vmware)

最近一直关注着一个国产系统的动态&#xff0c;至今已经更新到20版&#xff0c;界面优美&#xff0c;体验绝佳&#xff0c;舒适度绝对不比Mac本差&#xff0c;基于Linux内核开发自研的国产系统&#xff0c;真的是细微之处&#xff0c;体验不凡&#xff01;欢迎试水。 软件的生态…

如何安装 Deepin 20.1深度操作系统(图文) ?

Deepin 深度操作系统是一个用户友好的基于 Debian 的 Linux 发行版。它是一个免费和开源的操作系统&#xff0c;主要用于桌面级别。最近&#xff0c;Deepin 20.1 的稳定版本已经发布。Deepin 20.1 附带了稳定的内核版本 5.4 和 Debian 10.6 包存储库。 系统要求 More than 2 …

Windows+Deepin双系统的安装(win11+deepin20.7.1)

WindowsDeepin双系统的安装&#xff08;win11deepin20.7.1&#xff09; 目录 [Win11deepin20的安装方法](https://blog.csdn.net/m0_53397118/article/details/121883445#%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0Win11%2Bdeepin20%E7%9A%84%E5%AE%89%E8%A3%85%E6%96%…

window+deepin双系统安装

说明 参考教程&#xff1a;https://baijiahao.baidu.com/s?id1662960328855347503 特别注意&#xff0c;最好用最新的PE工具&#xff0c;我用的 微PE。因为我弄过一次全盘安装&#xff0c;导致整个硬盘在PE工具中的diskgenius无法识别&#xff0c;最终为U盘安装最新版PE工具后…

win10下安装deepin双系统教程

1、右键电脑—>管理—>磁盘管理&#xff0c;选择空闲容量多的磁盘压缩50G空间。 2、登录网址下载镜像和U盘制作工具&#xff08;启动盘制作不懂自行百度&#xff09;。 3、U盘插入电脑重新启动&#xff0c;按F10&#xff08;每个电脑品牌不一样&#xff0c;可百度&#x…

深度操作系统deepin下载与安装教程-系统安装

前往深度社区&#xff08;deepin.org&#xff09;&#xff0c;下载deepin最新的镜像文件 下载Ventoy启动盘制作工具 插入U盘后安装Ventoy制作多系统启动U盘 安装完成后将deepin镜像文件拷贝到Ventoy多系统启动U盘 插入用Ventoy制作的deepin启动盘 按电源开机键之后狂按F12&…

Linux(Deepin)如何安装NVIDIA显卡驱动(deepin-Linux)

Windows系统中我们知道&#xff0c;装一个Windows下的NVIDIA驱动是多么容易&#xff0c;然而&#xff0c;在Linux下如何安装NVIDIA驱动是一件多么“快乐”的事。。。 1、驱动下载 首先进入NVIDIA官网下载Linux的闭源驱动&#xff1a;NVIDIA官网驱动下载 找到对应显卡的驱动&a…

win10PC上安装deepin深度Linux系统简易教程

今天突然刷到deepin系统的新闻&#xff0c;心血来潮&#xff0c;自己电脑上安装一个&#xff0c;说干就干&#xff0c;总共分这么几个步骤&#xff1a; 1、在win10建立磁盘分区&#xff0c;用于后面步骤 &#xff08;1&#xff09;右击<我的电脑>&#xff0c;点击管理 …