#1 (permalink)  
Old 07-06-2007, 03:35 PM
curtiss's Avatar
Moderator
 
Join Date: May 2003
Posts: 1,438
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

  #2 (permalink)  
Old 08-07-2007, 03:40 PM
Registered User
 
Join Date: Aug 2007
Posts: 6
I don't think you're going to be able to do that. The reason being, I don't think you can put a WHERE condition on something that doesn't exist yet. I've never tried to do this and this is just my best guess.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Disable field2 select if field1 select value fails test schelly Programming and Scripting 1 05-06-2007 08:11 AM
Either/Or Select Options curtiss Programming and Scripting 0 01-04-2007 08:59 PM
listbox giving selected number -1 (select 2, get 1) gilgalbiblewhee Programming and Scripting 7 06-22-2006 01:17 PM
why doesn't it insert in database? gilgalbiblewhee Databases 4 06-16-2006 04:02 PM
SQL Problem with INSERT Jenny Databases 2 06-28-2005 09:24 AM


All times are GMT -5. The time now is 12:17 AM.

 
Bitrix
Clicky Web Analytics
CloudContacts
Maxtango


Subscribe to our feed | add to myYahoo!

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
© 1997-2007 HTMLCenter