0
我有兩個表,Fruits和Meals,Meals中的其中一列是varchar(100),其中包含水果。我正在改變這個,以便 這個列代替水果表中的水果的ID,我想通過比較這兩個表並從水果列匹配的水果表中抓取ID 來設置它。將table id從一列複製到另一列,其中列數據匹配表
Table: Fruits
id | fruit
1 apple
2 banana
3 orange
Table: Meals
id | Meal | Fruit
1 xxxx apple
2 xxxx apple
3 xxxx orange
4 xxxx banana
5 xxxx orange
6 xxxx orange
7 xxxx apple
我試過以下腳本,但出現以下錯誤。
Update product_attribute set control_caption =
(
Select DISTINCT T1.control_caption_id from control_caption T1
INNER Join product_attribute T2
On T1.control_caption = T2.control_caption
Where T1.control_caption = T2.control_caption
)
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
@MahmoudGamal這是一個MS SQLServer的錯誤。 – 2013-03-19 20:28:48