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

inserting text via append query

Status
Not open for further replies.

ITbeast

IS-IT--Management
Jul 25, 2006
67
US
Hello,

I'd like to have a query that pulls out records that are marked yes as callbacks, then inserts hard coded text into the fname_table and lname_table. Here is the SQL code behind my append queries, but when I run them nothing happens.

INSERT INTO fname_table ( formID, first_name, name_id )
SELECT dump_table.FormID, "BACK" AS Expr1, 1 AS Expr2
FROM dump_table INNER JOIN fname_table ON dump_table.FormID=fname_table.FormID
WHERE (((dump_table.call_back)=Yes));


INSERT INTO lname_table ( formID, last_name, name_id )
SELECT dump_table.FormID, "CALL" AS Expr1, 1 AS Expr2
FROM dump_table INNER JOIN lname_table ON dump_table.FormID=lname_table.FormID
WHERE (((dump_table.call_back)=Yes));
 
You may want to check to ensure the Where clause is interpreting the Yes as "Yes" i.e. include the quotes, especially if the field is set to a text field.

Cheers

Matt
 
You may also want to look at the primary keys in your target tables. If "formID" and/ or "name_id" are unique keys then you may get nothing inserted because you are duplicating key values.

Just looking at your SQL, it seems that your joins will pick up records that already exist in the tables that you are trying to load. That is,
Code:
SELECT dump_table.FormID, ...
FROM dump_table INNER JOIN lname_table ON dump_table.FormID=lname_table.FormID
guarantees that [blue]dump_table.FormID[/blue] is a value that already exists in [blue]lname_table.FormID[/blue]. Could that be causing you to be inserting duplicate records?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top