Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2004
    Posts
    3

    Unanswered: Project Question

    Hello,

    i have a small project. 2 tables A & B both have a sku and Price

    A B
    Sku Price Sku Price
    1 11 1 111
    2 22 2 222
    3 33


    What i need to do is update table A with the price from table B.. Where the SKu in Table A = Sku In table B (only Those) ie.. sku 3 whould not be looked at.

    i also have to get this info from excel spreadsheets. into table A.

    I hate school.

    Any help would be great.

  2. #2
    Join Date
    Mar 2004
    Posts
    480
    What do you have so far? Or should we do all the work for you?

  3. #3
    Join Date
    Mar 2004
    Posts
    3
    I dont want you to do the work for me. I just was in a jam. Im not very good at the Mysql stuff.

    Ive tried some update statemnts like this

    update A set A.price = B.Price where A.sku = B.sku ;

    Bu tthat does not work. So i thought I would ask.

  4. #4
    Join Date
    Mar 2004
    Posts
    480
    Originally posted by bignogin
    I dont want you to do the work for me. I just was in a jam. Im not very good at the Mysql stuff.

    Ive tried some update statemnts like this

    update A set A.price = B.Price where A.sku = B.sku ;

    Bu tthat does not work. So i thought I would ask.
    Lots of times people ask for work/homework/classwork to be done for them on boards. Folks don't mind helping out, but don't want to be doing everything, that's why i mentioned it.

    You can do

    UPDATE a, b
    SET a.price = b.price
    WHERE
    a.sku = b.sku
    AND
    b.sku is not null;

    This works if you have MySQL 4.0.4 or later.
    You have to denote the second table in the update, whereas you have only included table A in yours that might have generated the error.

    Previous to version 4.0.4 you can't update across multiple tables like this.

  5. #5
    Join Date
    Mar 2004
    Posts
    3
    it worked.. thanks a lot. This was just supposed to be a intrr to webdesign class. Im not in computer science, but wanted to experiment with webpages and stuff. So im trying to learn how to so this mysql stuff on my own.

  6. #6
    Join Date
    Mar 2004
    Posts
    480
    Originally posted by bignogin
    it worked.. thanks a lot. This was just supposed to be a intrr to webdesign class. Im not in computer science, but wanted to experiment with webpages and stuff. So im trying to learn how to so this mysql stuff on my own.
    Not a problem at all. You may find you like it enough that you have another question here or there. Make sure you come up with a good thread subject too, chances are people will be drawn to something they are sure they can answer rather than not. I know when I'm busy i just skim the thread headlines. Good luck in your class.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •