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!

How to pull one list from another 1

Status
Not open for further replies.

linousa

IS-IT--Management
Mar 8, 2013
79
US
What's the best way to pull one list from another? Have 2 tables and need to copy complete lines and delete them after:
Code:
table to be pulled from 50K:
janet
john
john
jack
joe
joe

list to be pulled 20K:
joe
jack
 
What do you mean by:
pull one list from another
Your example only shows individual text lines. It does not show what is a 'list'

If you mean how to pull specific rows from one table and put them into another, then that is something else.

With better clarification, we can better advise you.

Good Luck,
JRB-Bldr
 
I have two tables, both have the same field(account) and need to copy all records with the same account to a new table#3 and delete them after from table#1. Table#2 is just the list(one field) of the accounts that need to be pulled.
 
Just in case, make copies of TABLE1 & TABLE2 first.

Then
Code:
* --- [u]new[/u] table#3 - Assuming Table3 does not already exist ---
SELECT * FROM Table1 WHERE Account IN (SELECT Account FROM Table2) INTO TABLE Table3
DELETE FROM Table1 WHERE Account IN (SELECT Account FROM Table2)

SELECT Table3

Good Luck,
JRB-Bldr

 
Awesome! It worked... I definitely need to ready more about SQL SELECT. Thank you!
 
I am glad things worked for you.

There are a lot of SQL Command Tutorials out on the web.
Do a Google search for: sql command tutorial

However, note that there are a few different 'flavors' of the SQL Command set so learn things in general, but be prepared to possibly run into situations where one command or sub-command will not work due to database-specific requirements.

Good Luck,
JRB-Bldr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top