我在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) –