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 > Probs with update query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-26-09, 12:37
Jay59 Jay59 is offline
Registered User
 
Join Date: Sep 2006
Posts: 162
Probs with update query

The select statement works, but the update below does not. Did I do it wrong?


SELECT j.emp, j.job, j.sow_code, j.emp_sow_price, s.pay_rate
FROM job j
JOIN employee e ON j.emp = e.emp_id
JOIN sow_pay s ON j.sow_code = s.sow_code AND e.piece_payrate = s.pay_grade;


UPDATE job
SET emp_sow_price = s.pay_rate
FROM job j
JOIN employee e ON j.emp = e.emp_id
JOIN sow_pay s ON j.sow_code = s.sow_code AND e.piece_payrate = s.pay_grade;
Reply With Quote
  #2 (permalink)  
Old 09-26-09, 13:06
Jay59 Jay59 is offline
Registered User
 
Join Date: Sep 2006
Posts: 162
Sorry, i always figure it out after I've posted.

Below works.

UPDATE job j, employee e, sow_pay s
SET j.emp_sow_price = s.pay_rate
WHERE j.emp = e.emp_id AND e.piece_payrate = s.pay_grade
AND j.sow_code = s.sow_code AND j.emp_sow_price != s.pay_rate;
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