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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INSERT INTO and Select statement

Status
Not open for further replies.

montejr

Programmer
May 24, 2001
42
0
0
US
I am trying to populate the records of one field based on the value of another field. So if I have a value of 1 as my plan_id, I want the value of my Plan_Name to be plan1.

Essentially, I need to write a query to select a bunch of records and populate another field with new values based on the selected records. Here is my syntax so far:

INSERT INTO PascoCounty_Parcels (Plan_Name) VALUES (Plan1) SELECT * from PascoCounty_Parcels where PlanID = 1;

I get a "missing semicolon at end of SQL Statement" message. I think my syntax is wrong - it's been a while since I have done this.

Thanks,
Monte
 
I think you want to update records rather than insert new records. Maybe if you could show use about 4 or 5 before and after records, we could help more.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Like dhookom says, you want to update the record (by inserting a value in one of the fields -- this is where you are getting confused, I think).

UPDATE PascoCounty_Parcels SET Plan_Name = 'Plan' + PlanID

You probably don't need to do this though; you can derive the desired string when querying by concatenating the ID with a literal string:

Select PlanID, 'Plan' + PlanID AS PlanName FROM PascoCounty_Parcels
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top