Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / November 2007

Tip: Looking for answers? Try searching our database.

INSERT query - please help me.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mitchell_Collen - 29 Nov 2007 17:09 GMT
INSERT INTO Employee_Status ( [Employee Name], [Employee ID] )
SELECT [Employee List].[Employee Name], [Employee List].[Employee ID]
FROM [Employee List]
WHERE ((([Employee List].[Employee ID]) <> [Employee_Status].[Employee ID]));

I have no control over a linked table [Employee List] coming from managment
dept. I want to query to insert all employees and ids to another table called
Employee_Status (this table I will be able to create new columns such as
status on them) . That way, I can update either active/not active and create
reports/sign in sheets based on active employees only. I don't want to delete
non active employees. I know this sounds very spagetti. Will you please tell
how I can populate the table Employee_Status  with the linked table Employee
List?

Thanks, Misty
Amy Blankenship - 29 Nov 2007 18:01 GMT
> INSERT INTO Employee_Status ( [Employee Name], [Employee ID] )
> SELECT [Employee List].[Employee Name], [Employee List].[Employee ID]
[quoted text clipped - 16 lines]
> Employee
> List?

Since you're not talking about a particular row in Employee_Status, the
WHERE clause isn't going to work properly.  Possibly

WHERE [Employee List].[Employee ID] NOT IN (SELECT EmployeeID FROM
EmployeeStatus);

would work.  Note I changed your field names in the table you DO control to
make them easier to work with.

HTH;

Amy
Mitchell_Collen - 29 Nov 2007 22:05 GMT
Thanks Amy.
-Misty
>> INSERT INTO Employee_Status ( [Employee Name], [Employee ID] )
>> SELECT [Employee List].[Employee Name], [Employee List].[Employee ID]
[quoted text clipped - 14 lines]
>
>Amy
John W. Vinson - 29 Nov 2007 18:55 GMT
>I have no control over a linked table [Employee List] coming from managment
>dept. I want to query to insert all employees and ids to another table called
[quoted text clipped - 4 lines]
>how I can populate the table Employee_Status  with the linked table Employee
>List?

I'd suggest a "frustrated outer join" query. Amy's NOT IN query is another way
to do it, but Access can be very inefficient at processing such queries - this
alternative gets to the same result but may be much faster:

INSERT INTO Employee_Status ( [Employee Name], [Employee ID] )
SELECT [Employee List].[Employee Name], [Employee List].[Employee ID]
FROM [Employee List] LEFT JOIN [Employee_Status]
ON [Employee List].[Employee ID]=[Employee_Status].[Employee ID]
WHERE [Employee_Status].[Employee ID] IS NULL;

            John W. Vinson [MVP]
Mitchell_Collen - 29 Nov 2007 22:05 GMT
Thanks John.
-Misty

>>I have no control over a linked table [Employee List] coming from managment
>>dept. I want to query to insert all employees and ids to another table called
[quoted text clipped - 13 lines]
>
>             John W. Vinson [MVP]
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.