这是代码。有人能解释一下gi和ogi在这句话中的意思吗?
UPDATE `oceansne_website08`.`oc_gallery_image_description` ogi
LEFT Join `gallery_image_to_album` gi ON gi.image_id = ogi.gallery_image_id
SET
`gallery_album_id` = gi.album_id
WHERE ogi.gallery_album_id =0;
假设您有一个名为MyVeryLongTableNameThatIFindTediousToWrite
的表,并希望将其加入MyEvenLongerAndMoreTediousTableWithAnEvenLongerName
你可以写:
SELECT * FROM mydb.MyVeryLongTableNameThatIFindTediousToWrite
INNER JOIN myotherdb.MyEvenLongerAndMoreTediousTableWithAnEvenLongerName
ON mydb.MyVeryLongTableNameThatIFindTediousToWrite.id = myotherdb.MyEvenLongerAndMoreTediousTableWithAnEvenLongerName.otherId
WHERE myotherdb.MyEvenLongerAndMoreTediousTableWithAnEvenLongerName.value > 100
为了使其更清晰,您可以使用Alias,因此相同的选择可以写成:
SELECT * FROM mydb.MyVeryLongTableNameThatIFindTediousToWrite tbla
INNER JOIN myotherdb.MyEvenLongerAndMoreTediousTableWithAnEvenLongerName tblb
ON tbla.id = tblb.otherId
WHERE tblb.value > 100
在某些SQL风格中,您需要编写mydb.MyVeryLongTableNameThatIFindTediousToWrite AS tbla
,但这与的回答有点偏离主题
它是一个别名;引用示例中表格的缩写形式。
UPDATE `oceansne_website08`.`oc_gallery_image_description` ogi
LEFT JOIN `gallery_image_to_album` gi
ON gi.image_id = ogi.gallery_image_id
SET `gallery_album_id` = gi.album_id
WHERE ogi.gallery_album_id =0
这里ogi指的是表格-->oceansne_website08
。oc_gallery_image_description
gi指表格-->gallery_image_to_album