Try running it this way.


Insert Into Colors
(Color_Code)
(SELECT DISTINCT Product.Color_Code
FROM Products, Colors
Where Colors.Hex_Code = Products.Hex_Code)

-----Original Message-----
From: Bruce Sorge [mailto:[EMAIL PROTECTED]
Sent: Tuesday, February 03, 2004 9:36 AM
To: SQL
Subject: Insert Sub-Query Issue

I have a sub-query that I am using to insert some data into a database:

Insert Into Colors
(Color_Code)
(SELECT DISTINCT Color_Code
FROM Products
Where Colors.Hex_Code = Products.Hex_Code)

When I run this, I get the message:
Server: Msg 107, Level 16, State 3, Line 1
The column prefix 'Colors' does not match with a table name or alias name
used in the query.

Why is this?

If I put a single quote around Colors.Hex_Code, then I get 0 row(s)
affected.

Thanks,

Bruce
  _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to