gpt4 book ai didi

c# - 如何在插入语句中使用子查询

转载 作者:太空宇宙 更新时间:2023-11-03 17:52:25 24 4
gpt4 key购买 nike

我已经尝试过,但出现错误:


  在此上下文消息中不允许出现SubQuery。


我有两个表ProductCategory,并且要基于categoryId使用CategoryName

查询是

Insert into Product(Product_Name,Product_Model,Price,Category_id) 
values(' P1','M1' , 100, (select CategoryID from Category where Category_Name=Laptop))


请告诉我一个带有代码的解决方案。

最佳答案

这样尝试

Insert into Product
(
Product_Name,
Product_Model,
Price,Category_id
)
Select
'P1',
'M1' ,
100,
CategoryID
From
Category
where Category_Name='Laptop'

关于c# - 如何在插入语句中使用子查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20771820/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com