Append Query

D

denton

I have a table of trades and each has an account number. I want to create a
table of all account numbers where account numbers will be the primary key.
How do I write a query that insert but prevents duplicated account entry?

// <-- signifies comment
// This query below inserts all account #'s

INSERT INTO Accounts ( account_code )
SELECT Trades.account_code
FROM Trades
 
D

Damian S

Hi Denton,

You are almost there... just need to group your results like this:

INSERT INTO Accounts ( account_code )
SELECT Trades.account_code
FROM Trades
group by Trades.account_code

Hope this helps.

Damian.
 
Top