Link to home
Start Free TrialLog in
Avatar of jlcannon
jlcannon

asked on

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

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.
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

post sample data from your table
How about this:

UPDATE tblDataLocation SET tblDataLocation.Folder = Null, tblDataLocation.Drive = "Stuff"
WHERE (((tblDataLocation.Folder)="Stuff"));
Sorry, use this WHERE:

WHERE (((tblDataLocation.Folder)="Stuff") AND ((tblDataLocation.Drive)="Personal"));
Avatar of jlcannon
jlcannon

ASKER

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)
<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
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.
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
ASKER CERTIFIED SOLUTION
Avatar of TWBit
TWBit
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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