易截截图软件、单文件、免安装、纯绿色、仅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 ......

关于Vb中sql语句的写法(100分) - Java / Web 开发

求个vb中的sql语句的写法,次sql语句的用法是分页程序
我写的如下:其中A是用来接收每页显示的记录的条数,B是用来接收显示的当前的页面.
sqltext="select top A * from log where id not in(select top ( ......

求一条SQL语句 - MS-SQL Server / 应用实例

原SQL语句SQL code:

SELECT t6.FName '操作工',t1.FDate '日期',t5.FName '制单人',t3.FName '设备',t4.FName '班制',
t7.FBillNo '工艺指令单号',t8.FName '岗位',t2. ......

sql语句问题 - MS-SQL Server / 疑难问题

现在有一个部门表dept(部门名称,部门号。。)有一个人员表emp(姓名,人员编号,职位,薪资,部门)
emp表中的内容是这样的:
a 1 工程师 3000 软件部
b 2 普通员工 2000 硬件部
c 3 工程师 4000 硬件部
d ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号