Solved

How to write a query that will move data within a table

Posted on 2007-11-29
9
179 Views
Last Modified: 2010-05-18
I have a table called tblDataLocation and there are fields named  "Drive" and "folder". when i first began this database I had some data that was just a small amout so it was under "Personal" in the "drive" column and in the "folder" column under "Stuff".. well now "Stuff" has gotten so big  i want to copy all the records under the column "drive" with a name of "personal" and under "folder" with the name of "stuff" to now be moved to the column "drive" with a name of "Stuff" and the  "folder" column left blank cause i will add that later.
0
Comment
Question by:jlcannon
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
post sample data from your table
0
 
LVL 11

Expert Comment

by:TWBit
Comment Utility
How about this:

UPDATE tblDataLocation SET tblDataLocation.Folder = Null, tblDataLocation.Drive = "Stuff"
WHERE (((tblDataLocation.Folder)="Stuff"));
0
 
LVL 11

Expert Comment

by:TWBit
Comment Utility
Sorry, use this WHERE:

WHERE (((tblDataLocation.Folder)="Stuff") AND ((tblDataLocation.Drive)="Personal"));
0
 

Author Comment

by:jlcannon
Comment Utility
well i cant really post the data since it is confidential data and the names of the fields have been changed to protect the innocent.. but in the table there is a column named "Drive" and a coulumn named "Folder" and I want to take everythink under the column"Drive" that = "Personal" and under "Folder" that = "stuff" and move it to where under "drive" = to "stuff" and under "folder" = (blank)
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
<well i cant really post the data since it is confidential data>
create dummy data, so we can understand better what is need to be done
0
 

Author Comment

by:jlcannon
Comment Utility
https://filedb.experts-exchange.com/incoming/ee-stuff/5885-sampletable.JPG

here is a screen shot of the table i am refereing to. and the data i am needing to move is under the column labled plant as tree and under the location as house and I want to move that data to where the plant is house and the location is left blank.
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
sorry for  being dense today, maybe need more coffee.
but, can you post another screen shot of the final look of the table after the update
0
 
LVL 11

Accepted Solution

by:
TWBit earned 500 total points
Comment Utility
I guess I don't see why my query wouldn't work.  I've updated it with your references (with what I could read from the screenshot):

UPDATE tblRelays SET tblRelays.Location = Null, tblRelays.Area= "Stuff"
WHERE (((tblRelays.Location)="Stuff") AND ((tblRelays.Area)="Personal"));
0
 
LVL 17

Expert Comment

by:Shanmuga Sundaram
Comment Utility
why a big confusion. Select the needed fields and insert it into temporary table. For eg. Select a.field1 as field1, a.field2 as field2, b.field1 as field3,b.field2 as field4 into newtablename from table1 a, table2 b where a.fieldx=b.fieldy
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
MS SQL Bulk load data error 5 30
encyps queries mssql 15 24
Search field on a form 7 12
Error in SQL Query 36 33
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now