易截截图软件、单文件、免安装、纯绿色、仅160KB

求教各位大神2表查询的 - MS-SQL Server / 疑难问题

表T_Kind K_ID K_Name K_Kind
  1 球 0
  2 人 0
  3 篮球 1
  4 足球 1
  5 男人 2
  5 妖人 2
表T_P P_ID P_Name P_Kind
  1 乒乓球 1
  2 NBA 3

表T_P的P_Kind和表T_Kind的K_ID 对应。我现在想查出T_P表中根据表T_Kind关联的那2条记录:

SQL code:
--> 测试数据:#T_Kind
if object_id('tempdb.dbo.#T_Kind') is not null drop table #T_Kind
go
create table #T_Kind([K_ID] int,[K_Name] varchar(4),[K_Kind] int)
insert #T_Kind
select 1,'球',0 union all
select 2,'人',0 union all
select 3,'篮球',1 union all
select 4,'足球',1 union all
select 5,'男人',2 union all
select 5,'妖人',2
--> 测试数据:#T_P
if object_id('tempdb.dbo.#T_P') is not null drop table #T_P
go
create table #T_P([P_ID] int,[P_Name] varchar(6),[P_Kind] int)
insert #T_P
select 1,'乒乓球',1 union all
select 2,'NBA',3

--------------------------------查询开始------------------------------
select t.* from #T_Kind t,#T_P p where t.K_ID = p.[P_Kind]
/*
K_ID K_Name K_Kind
----------- ------ -----------
1 球 0
3 篮球 1

(2 行受影响)

*/

是这个意思吗?

sel


相关问答:

jsp链接sql2000的疑问?



type Exception report


message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jas ......

数据以xml格式返回 - MS-SQL Server / 应用实例

从数据库中查询一张表的数据
select 部门,姓名 from tb
如何才能生成下面的xml格式
XML code:
<folder state="unchecked" label="全部">
   <folder state="unchecked&qu ......

求一个SQL语句 - MS-SQL Server / 基础类

字段1,字段2.....字段N,Status,ParentID
1,Name1....test1,1,99
1,Name1....test1,3,99
1,Name2....test2,1,101
1,Name2....test2,3,101
1,Name3....test3,2,101
1,Name1....test1,4,101
想要的结果是:
1,Na ......

请教SQL语句查询问题? - MS-SQL Server / 基础类

我想查询出每天数据的最大的一个值。表的格式如下
表名: hisdata
字段 编号 值 状态 时间  
  Id value state dattime  
  101 32.3 0 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号