Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Append Query to Append AND Add Constant Value

Status
Not open for further replies.

Melagan

MIS
Nov 24, 2004
443
US
Greetings,

I'm looking to run an append query to append multiple values to an existing table but also want the append query to add a constant value to each record. The following example data and desired results should help to explain further:

Code:
Data to append:

Address   Date      County
1 Main    3/8/2006  
2 Main    3/8/2006
3 Jones   3/9/2006
12 Mark   3/10/2006


On main table, after append:

Address   Date      County
1 Main    3/8/2006  Fresno
2 Main    3/8/2006  Fresno
3 Jones   3/9/2006  Fresno
12 Mark   3/10/2006 Fresno

Any ideas?



~Melagan
______
"It's never too late to become what you might have been.
 
I think you want an UPDATE (not Append) query because you are changing existing records and not adding new ones.
Code:
UPDATE myTable Set County = 'Fresno'
 
I actually do want an append...the example data in the second table never existed before the append query. Thats why I want it to append data and add data at the same time.



~Melagan
______
"It's never too late to become what you might have been.
 
OK. I misunderstood. If your source data (i.e. the stuff you want to APPEND) is in another table then
Code:
INSERT INTO myTable (Address, Date, County)
Select Address, [Date], 'Fresno' As County
From SourceTable

If the values to be inserted are not available in another table then
Code:
INSERT INTO myTable (Address, Date, County)
VALUES ('1 Main', #3/8/2006#, 'Fresno' )

INSERT INTO myTable (Address, Date, County)
VALUES ('2 Main', #3/8/2006#, 'Fresno' )

etc.
 
Just little things here and there make databases way cool -thanks man, worked wonders!



~Melagan
______
"It's never too late to become what you might have been.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top