我在SQL Server中创建这个简单的数据库:内侧内SELECT TOP JOIN
create database product_test
go
use product_test
go
create table product
(
id int identity primary key,
label varchar(255),
description text,
price money,
);
create table picture
(
id int identity primary key,
p_path text,
product int foreign key references product(id)
);
insert into product
values ('flip phone 100', 'back 2 the future stuff.', 950),
('flip phone 200', 's;g material', 1400)
insert into picture
values ('1.jpg', 1), ('2.jpg', 1), ('3.jpg', 2)
我想是选择所有产品和只有一个画面的每一个产品。任何帮助是极大的赞赏。
你尝试'内加入(选择顶部1等从大声笑)img on img.whatever = outer.whatever'? – Will
你想要哪张照片? – Hogan
未来版本的SQL Server中将删除'ntext','text'和'image'数据类型。避免在新的开发工作中使用这些数据类型,并计划修改当前正在使用它们的应用程序。改为使用'nvarchar(max)','varchar(max)'和'varbinary(max)'。 (详见这里)(http://msdn.microsoft.com/en-us/library/ms187993.aspx) –