数据库多表查询sql语句
@从柳380:如何用一个sql分别从两个表中查询数据 -
丰丹14794471418…… sql语句从一张表中查询数据插入到另一张表中的方法如下: 1、select * into destTbl from srcTbl. 2、insert into destTbl(fld1, fld2) select fld1, 5 from srcTbl.以上两句都是将 srcTbl 的数据插入到 destTbl,但两句又有区别的:第一句(select into from)要求目标表(destTbl)不存在,因为在插入时会自动创建.第二句(insert into select from)要求目标表(destTbl)存在,由于目标表已经存在,所以我们除了插入源表(srcTbl)的字段外,还可以插入常量.
@从柳380:例举几条多表查询SQL语句 -
丰丹14794471418…… 1.select a.学号,a.姓名,b.学籍号,a.性别,a.民族,a.身份证号,a.联系电话 from 学生表 a, 注册表 b 2.select count (*) [注册人数]from 注册表 where 注册时间='2010-10-20'(select 专业代码,专业名称,总金额 from 专业表,注册表,收据表 where 注册时间='2010-10-20') 3.select a.所属院系,b.性别,c.房间号,床位状态 from 专业表 a, 学生表 b,房间表,床位表 c where 床位状态 = '空位'
@从柳380:SQL数据库多表查询语句 -
丰丹14794471418…… where a.房间类型编号 = b.房间类型编号 and not exists (select 1 from 表c c where a.房间号 = c.房间号) and not exists (select 1 from 表d d where a.房间号 = d.房间号)
@从柳380:关于多表联合查询的SQL语句...求解释下.... -
丰丹14794471418…… --T-SQL语句表示如下,没什么可说的 就是多表条件联接而已,取F表不重复的条件联接下的所有记录 --输入参数为UserName,最后再以f.showorder排序 select distinct f.* from qx_grouppermit a,qx_usergroup b,xt_user c,qx_model d,qx_model e,...
@从柳380:求一条多表查询的sql语句,高手请进 -
丰丹14794471418…… select 表1.*,表2.time1,表2.time2,表3.test from 表1,表2,表3 where 表1.cd=表2.id and 表1.cd=表3.id and (表1.time between('2008-4-1','yyyy-mm-dd') and ('2008-4-30','yyyy-mm-dd'))
@从柳380:mysql多表查询sql语句怎么写? -
丰丹14794471418…… 一使用SELECT子句进行多表查询 SELECT 字段名 FROM 表1,表2 … WHERE 表1.字段 = 表2.字段 AND 其它查询条件 SELECT a.id,a.name,a.address,a.date,b.math,b.english,b.chinese FROM tb_demo065_tel AS b,tb_demo065 AS a WHERE ...
@从柳380:请教多个表查询统计的一个SQL语句 -
丰丹14794471418…… 请教多个表查询统计的一个SQL语句 select count(*) from [table name1]+ select count(*) from [table name2]+ select count(*) from [table name3]
@从柳380:如何使用SQL语句进行多表查询? -
丰丹14794471418…… SQL多表查询最经常使用的就是链接查询:select * from Aleft jion B on A.ID=B.AID链接的方式有很多种,会影响到查询的结果.
@从柳380:请教一条SQL语句. 多表联查 -
丰丹14794471418…… select * from A inner join B on A.code=B.code left join C on A.code=C.code
@从柳380:sql语句一对多表的查询方式怎么写 -
丰丹14794471418…… 使用SELECT子句进行多表查询 SELECT a.id,a.user, b.message FROM user AS a,message AS b WHERE a.id=b.id
丰丹14794471418…… sql语句从一张表中查询数据插入到另一张表中的方法如下: 1、select * into destTbl from srcTbl. 2、insert into destTbl(fld1, fld2) select fld1, 5 from srcTbl.以上两句都是将 srcTbl 的数据插入到 destTbl,但两句又有区别的:第一句(select into from)要求目标表(destTbl)不存在,因为在插入时会自动创建.第二句(insert into select from)要求目标表(destTbl)存在,由于目标表已经存在,所以我们除了插入源表(srcTbl)的字段外,还可以插入常量.
@从柳380:例举几条多表查询SQL语句 -
丰丹14794471418…… 1.select a.学号,a.姓名,b.学籍号,a.性别,a.民族,a.身份证号,a.联系电话 from 学生表 a, 注册表 b 2.select count (*) [注册人数]from 注册表 where 注册时间='2010-10-20'(select 专业代码,专业名称,总金额 from 专业表,注册表,收据表 where 注册时间='2010-10-20') 3.select a.所属院系,b.性别,c.房间号,床位状态 from 专业表 a, 学生表 b,房间表,床位表 c where 床位状态 = '空位'
@从柳380:SQL数据库多表查询语句 -
丰丹14794471418…… where a.房间类型编号 = b.房间类型编号 and not exists (select 1 from 表c c where a.房间号 = c.房间号) and not exists (select 1 from 表d d where a.房间号 = d.房间号)
@从柳380:关于多表联合查询的SQL语句...求解释下.... -
丰丹14794471418…… --T-SQL语句表示如下,没什么可说的 就是多表条件联接而已,取F表不重复的条件联接下的所有记录 --输入参数为UserName,最后再以f.showorder排序 select distinct f.* from qx_grouppermit a,qx_usergroup b,xt_user c,qx_model d,qx_model e,...
@从柳380:求一条多表查询的sql语句,高手请进 -
丰丹14794471418…… select 表1.*,表2.time1,表2.time2,表3.test from 表1,表2,表3 where 表1.cd=表2.id and 表1.cd=表3.id and (表1.time between('2008-4-1','yyyy-mm-dd') and ('2008-4-30','yyyy-mm-dd'))
@从柳380:mysql多表查询sql语句怎么写? -
丰丹14794471418…… 一使用SELECT子句进行多表查询 SELECT 字段名 FROM 表1,表2 … WHERE 表1.字段 = 表2.字段 AND 其它查询条件 SELECT a.id,a.name,a.address,a.date,b.math,b.english,b.chinese FROM tb_demo065_tel AS b,tb_demo065 AS a WHERE ...
@从柳380:请教多个表查询统计的一个SQL语句 -
丰丹14794471418…… 请教多个表查询统计的一个SQL语句 select count(*) from [table name1]+ select count(*) from [table name2]+ select count(*) from [table name3]
@从柳380:如何使用SQL语句进行多表查询? -
丰丹14794471418…… SQL多表查询最经常使用的就是链接查询:select * from Aleft jion B on A.ID=B.AID链接的方式有很多种,会影响到查询的结果.
@从柳380:请教一条SQL语句. 多表联查 -
丰丹14794471418…… select * from A inner join B on A.code=B.code left join C on A.code=C.code
@从柳380:sql语句一对多表的查询方式怎么写 -
丰丹14794471418…… 使用SELECT子句进行多表查询 SELECT a.id,a.user, b.message FROM user AS a,message AS b WHERE a.id=b.id