A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Insert Into syntax help



 
 
Thread Tools Display Modes
  #1  
Old February 13th, 2007, 01:12 PM posted to microsoft.public.access.queries
XP
external usenet poster
 
Posts: 43
Default Insert Into syntax help

Using Office 2003 and Windows XP;

Can someone please help me clear the syntax error I'm getting from this SQL?:

INSERT INTO
Table1 AS A
SELECT B.SAL_ADMIN_PLAN, B.PAY_GRADE,
B.ANNUAL_MIN, B.ANNUAL_MID, B.ANNUAL_MAX
FROM Table2 AS B
WHERE
(A.SAL_ADMIN_PLAN B.SAL_ADMIN_PLAN AND
A.PAY_GRADE B.PAY_GRADE);

Note that in the WHERE clause both specs must be true;
As you may be able to tell, I am not that good with SQL; please help.

Thanks much in advance.
  #2  
Old February 13th, 2007, 01:47 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default Insert Into syntax help

You are referring to Table1 in the SELECT query. To do so, it must be in
the FROM clause of the SELECT query. I also assume that you are creating
Table1 or that Table1 has exactly 5 fields and in the order that you
specified in SELECT query.

INSERT INTO Table1 AS A
SELECT B.SAL_ADMIN_PLAN
, B.PAY_GRADE
, B.ANNUAL_MIN
, B.ANNUAL_MID
, B.ANNUAL_MAX
FROM Table2 AS B RIGHT JOIN Table1 as C
ON A.SAL_ADMIN_PLAN = C.SAL_ADMIN_PLAN AND
A.PAY_GRADE = C.PAY_GRADE
WHERE C.SAL_ADMIN_PLAN IS NULL

A good way to handle this type of thing is to construct just the Select
query first and see if it returns the records and fields you want. Once
that is done, then add the INSERT part of the append query.


--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

"XP" wrote in message
...
Using Office 2003 and Windows XP;

Can someone please help me clear the syntax error I'm getting from this
SQL?:

INSERT INTO
Table1 AS A
SELECT B.SAL_ADMIN_PLAN, B.PAY_GRADE,
B.ANNUAL_MIN, B.ANNUAL_MID, B.ANNUAL_MAX
FROM Table2 AS B
WHERE
(A.SAL_ADMIN_PLAN B.SAL_ADMIN_PLAN AND
A.PAY_GRADE B.PAY_GRADE);

Note that in the WHERE clause both specs must be true;
As you may be able to tell, I am not that good with SQL; please help.

Thanks much in advance.



  #3  
Old February 13th, 2007, 01:50 PM posted to microsoft.public.access.queries
XP
external usenet poster
 
Posts: 43
Default Insert Into syntax help


Please note that Table1 already includes some of the records in Table2; I am
trying to get only those that did not match other criteria.

"XP" wrote:

Using Office 2003 and Windows XP;

Can someone please help me clear the syntax error I'm getting from this SQL?:

INSERT INTO
Table1 AS A
SELECT B.SAL_ADMIN_PLAN, B.PAY_GRADE,
B.ANNUAL_MIN, B.ANNUAL_MID, B.ANNUAL_MAX
FROM Table2 AS B
WHERE
(A.SAL_ADMIN_PLAN B.SAL_ADMIN_PLAN AND
A.PAY_GRADE B.PAY_GRADE);

Note that in the WHERE clause both specs must be true;
As you may be able to tell, I am not that good with SQL; please help.

Thanks much in advance.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:16 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.