View Single Post
  #1 (permalink)  
Old 07-06-2007, 03:35 PM
curtiss's Avatar
curtiss curtiss is offline
Moderator
 
Join Date: May 2003
Posts: 1,468
SELECT (INSERT) subqueries

I have just recently found out about subqueries, and I am curious about something. I know that you can place a SELECT query inside of an INSERT query, in order to pull information from one table and insert it into another. However, I am looking to see if there is any way to place an INSERT query inside of a SELECT query.

Let me explain what I am doing, in order to help clarify:

I have a table set up for my employees' contact information. When you add an employee to the table, an employee number is automatically generated (an Auto-Number column in Access 2003). That column is the only column within my table that will be completely unique. I need to have a reliable, accurate way to pull that employee number back out of the database in order to use it in another table.

The query I have tried (that didn't work) is:
Code:
SELECT `employeeid` FROM `employees`
WHERE (
INSERT INTO `employees`
(`firstname`, `lastname`, `emailusername`, `location`, `roomnumber`, `officephone`, `position`)
VALUES ('Curtiss', 'Grymala', 'cgrymala', 1, 'MC6', 5408698564, 'Webmaster')
);
Any suggestions on how to do that correctly?
__________________
I hate Internet Explorer! Anyone with me?
Reply With Quote