SQL database help

Discussion in 'Databases' started by goal442, Jul 20, 2011.

  1. #1
    I need to do the following and hope there is a statement/function that can make my life easier.

    I have two tables called Table1 and Table2
    Table1 has 1 field called Field1
    Table2 has 2 fields called Field2 and Field3

    I need to move some of the value from Field1 to Field2 and some to Field3
    So at the end Field1 would be empty.

    Is there a statement that can do the following:
    Go to Table1/Field1
    if the value of field1 starts with xyz and ends with zyx then move it to Field2
    if the value of field1 starts with abc and end with cba then move it to field3

    Thank you in advance
     
    goal442, Jul 20, 2011 IP
  2. mike4uuu

    mike4uuu Active Member

    Messages:
    832
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    60
    #2
    there are some software to alter the table easily in a database , forgot the exact name of the software , just try looking in google..
     
    mike4uuu, Jul 20, 2011 IP
  3. plog

    plog Peon

    Messages:
    298
    Likes Received:
    11
    Best Answers:
    1
    Trophy Points:
    0
    #3
    The easiest way would be 2 insert or update queries and a deletion query. The first one would test your for xyz/zyx and insert or append it into Field2. The second query would do the same for abc/cba and Field3. The deletion query would then delete any records in Table 1 that were xyz/zyx or abc/cba.

    I fear though that your problem is more complicated than that. Is this something that you need to to regularly or one time? Why does this data have to 'move'--are you elimanating Table 1 altogether? Can you be more specific in what your data is for?
     
    plog, Jul 22, 2011 IP
  4. unknownpray

    unknownpray Active Member

    Messages:
    3,831
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    70
    #4
    You can move da\ta from one field to another and making previous one empty by using this code INSERT ... (field_1, field_6, field_2, field_8) VALUES (value_1, value_6, value_2, value_8) and if you want more information you can gor for w3school.com.There you can find many examples.
     
    unknownpray, Jul 30, 2011 IP