我只是想知道如何根据表A col值从表B中选择值;这个想法很简单,但我有点困惑
像一样的代码DECLARE @A TABLE
(
id INT NOT NULL,
name VARCHAR(50)
);
INSERT @A SELECT id,name FROM table1 WHERE id>10
DECLARE @B TABLE
(
address VARCHAR(255),
city VARCHAR(128)
);
INSERT @b SELECT address,city FROM table2
WHERE id=(SELECT id FROM @A)
答案 0 :(得分:1)
将“id =”更改为“id IN”
WHERE id=(SELECT id FROM @A)
到
WHERE id IN (SELECT id FROM @A)