在mysql数据库上创建图像幻灯片放映

时间:2014-06-06 05:39:08

标签: mysql

我的数据库中有一个表格图像,可以存储一个产品的四个图像。我想当用户搜索特定产品时,使用该产品的相应图像ID为该产品生成图像幻灯片放映。谢谢。

$sql5="create table if not exists product(
prdid int(10) not null auto_increment primary key,
type enum('house','car') not null,
p_date timestamp not null DEFAULT CURRENT_TIMESTAMP,
amount varchar(15) not null,
description varchar(255) not null,
status enum('1','0') not null default '0',
prdfk int(10) not null,
foreign key(prdfk) references users(usid) on delete cascade
)DEFAULT CHARACTER SET utf8 ENGINE=InnoDB";


$sql6="create table if not exists images(
imgid int(10) not null auto_increment primary key,
name varchar(50) not null,
mimetype varchar(55) not null,
fielddata mediumblob not null,
imgfk int(10) not null,
foreign key(imgfk) references product(prdid) on delete cascade
)DEFAULT CHARACTER SET utf8 ENGINE=InnoDB";

1 个答案:

答案 0 :(得分:0)

这应该有效:

select fielddate, mimetype, name from image join prduct on imgfk = prdid where prdi=<your productid>