我在尝试向表中插入一些值时遇到问题。我用字段做了一个空表
id(primary key)
association_id
resource_id
我还有一张桌子
resource_id
association_id
还有一个
id(coresponding to the association_id in the former one)
image
我想从第一个填充的表中插入resource_id
和association_id
,其中最后一个表的coresponding ID的图像字段不为空。
我尝试了这个:
INSERT IGNORE INTO `logo_associations` (``,`association_id`,`resource_id`)
SELECT
``,
`a`.`association_id`,
`a`.`resource_id`
FROM doc24_associations_have_resources a
Join doc24_associations An on a.association_id = An.id
WHERE An.image<>''
但它不起作用
我的经验是基于SQL Server的,但是SQL可能非常相似
INSERT INTO DestinationTable
(association_id, resource_id)
SELECT LNK.assocication_id,
LNK.resource_id
FROM LinkTable AS LNK
INNER JOIN ImageTable AS IMG ON IMG.id = LNK.association_id
AND IMG.image IS NOT NULL
在上面,我假设以下内容:
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句