在这个SQL语句中,ogi和gi的含义是什么



这是代码。有人能解释一下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_website08oc_gallery_image_descriptiongi指表格-->gallery_image_to_album

相关内容

  • 没有找到相关文章

最新更新