If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Project Question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-29-04, 12:35
bignogin bignogin is offline
Registered User
 
Join Date: Mar 2004
Posts: 3
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.
Reply With Quote
  #2 (permalink)  
Old 03-29-04, 14:54
guelphdad guelphdad is offline
Registered User
 
Join Date: Mar 2004
Posts: 440
What do you have so far? Or should we do all the work for you?
Reply With Quote
  #3 (permalink)  
Old 03-29-04, 23:14
bignogin bignogin is offline
Registered User
 
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.
Reply With Quote
  #4 (permalink)  
Old 03-30-04, 08:49
guelphdad guelphdad is offline
Registered User
 
Join Date: Mar 2004
Posts: 440
Quote:
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.
Reply With Quote
  #5 (permalink)  
Old 03-30-04, 12:05
bignogin bignogin is offline
Registered User
 
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.
Reply With Quote
  #6 (permalink)  
Old 03-30-04, 14:26
guelphdad guelphdad is offline
Registered User
 
Join Date: Mar 2004
Posts: 440
Quote:
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On