might as well go ahead and ask my other two mysql questions

Discussion in 'MySQL' started by mnymkr, Jun 25, 2007.

  1. #1
    here are two big questions i am exploring.

    1) How could I change a whole row of data according to a key?

    I asked this in the php threads but then I realized where I really need to change this is in the database.

    so e needs to become egg
    and b needs to become ball


    2) if I need something to sort but according to a non natural sort

    a good example is in the diamond business

    IF is the best normal diamond, VVS2 next best then way under it is IS or SI something,

    so the natural sort would be alphabetical but the unatural sort would be the best diamon to worst diamond grade.
     
    mnymkr, Jun 25, 2007 IP
  2. flippers.be

    flippers.be Peon

    Messages:
    432
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    > 1) How could I change a whole row of data according to a key?
    > so e needs to become egg
    > and b needs to become ball

    update mytable set mycol='egg' where mycol='e'

    > so the natural sort would be alphabetical but the unatural sort would be the
    > best diamon to worst diamond grade

    easy fix: add a new column grade_int or so and put 1, 2, 3, 4 in it for the different grades and sort on that, instead of sorting on the code

    if you're smart then don't put 1, 2, 3 but 100, 200, 300 so you can add numbers in between if something needs to be changed later

    another solution is to make a lookup table and join with that, but that may complicate it too much for you
     
    flippers.be, Jun 25, 2007 IP
  3. mnymkr

    mnymkr Well-Known Member

    Messages:
    2,328
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    120
    #3
    I would love to hear more about how to use the left join, i can change the table as the guy i am building tihs for hopes to just upload his csv with no changes...
     
    mnymkr, Jun 26, 2007 IP