注册 登录
编程论坛 ASP.NET技术论坛

请教一个简单的SQL查询语句,高手请进

by_1782 发布于 2008-09-28 10:31, 733 次点击
/* 题目一:查询表1绑定列表,

条件是如果表2中的id_1等于表1中的id_1 并且表2中的tag等于Y,以及表2中的uname等于aaa的时候不读取表1中的该条记录,

其余全读取。*/

create database test_002

use test_002

create table table1            --表1
(
id_1 int primary key identity,
title nvarchar(50),
)

insert into table1(title) values('第一条')
insert into table1(title) values('第二条')
insert into table1(title) values('第三条')

create table table2            --表2
(
id_2 int primary key identity,
id_1 int,
tag nvarchar(10),
uname nvarchar(10)
)

insert into table2(id_1,tag,uname) values(2,'N','aaa')
insert into table2(id_1,tag,uname) values(1,'N','bbb')
0 回复
1