Solved

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

Posted on 2007-11-29
9
185 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 20374740
post sample data from your table
0
 
LVL 11

Expert Comment

by:TWBit
ID: 20374789
How about this:

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

Expert Comment

by:TWBit
ID: 20374801
Sorry, use this WHERE:

WHERE (((tblDataLocation.Folder)="Stuff") AND ((tblDataLocation.Drive)="Personal"));
0
 Watch the Recording: Learning MySQL 5.7

MySQL 5.7 has a lot of new features. If you've dabbled with an older version of MySQL, it is definitely worth learning.

 

Author Comment

by:jlcannon
ID: 20374802
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
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 20374841
<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
ID: 20374986
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 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 20375253
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
ID: 20375303
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
ID: 20375316
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

Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

617 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