我有以下表格:
CREATE TABLE IF NOT EXISTS "image_e"
(
"id" int unsigned NOT NULL AUTO_INCREMENT,
"title" varchar(32),
"alt" varchar(16) NOT NULL,
PRIMARY KEY ("id")
) ENGINE = MyISAM DEFAULT CHARSET = utf8 COLLATE = utf8_bin;
CREATE TABLE IF NOT EXISTS "image_version_e"
(
"id" int unsigned NOT NULL AUTO_INCREMENT,
"imageId" int unsigned NOT NULL,
"format" varchar(4) NOT NULL,
"size" int unsigned NOT NULL,
"width" smallint unsigned NOT NULL,
"height" smallint unsigned NOT NULL,
"src" varchar(64) NOT NULL,
PRIMARY KEY ("id")
) ENGINE = MyISAM DEFAULT CHARSET = utf8 COLLATE = utf8_bin;
ALTER TABLE "image_version_e"
ADD UNIQUE KEY ("imageId", "format", "width", "height"),
ADD UNIQUE KEY ("src");
我想将这些加入表格以将图像行与其关联的图像版本行链接起来。我加入他们的顺序真的很重要吗?如果我这样做有什么区别:
SELECT *
FROM image_e
LEFT JOIN image_version_e
ON image_version_e.imageId = image_e.id
代替 :
SELECT *
FROM image_version_e
LEFT JOIN image_e
ON image_e.id = image_version_e.id