Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Database Server Software > MySQL > Another Update question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-04-07, 20:11
mvreade mvreade is offline
Registered User
 
Join Date: Sep 2006
Posts: 19
Another Update question

Two table (that matter right now): rooms and events.

Here's the failed code:

UPDATE rooms SET available = 'No', availableQty = 0 WHERE rooms.event_ID = events.event_ID AND events.active = 'No'

Not quite sure what to do.

Thanks,

mvreade
Reply With Quote
  #2 (permalink)  
Old 10-05-07, 02:18
swapnilclarion swapnilclarion is offline
Registered User
 
Join Date: May 2007
Posts: 8
Hi,

Actually if you see your query properly it does not mention both the tables. But you are using those in WHERE clause.

Try this...

UPDATE rooms,events SET rooms.available = 'No', rooms.availableQty = 0 WHERE rooms.event_ID = events.event_ID AND events.active = 'No'

Thanks,
__________________
Swapnil Patil
DB Team @ Clarion
Clarion Technologies
(SEI CMMI Level 3)
Pune, India
www.clariontechnologies.co.in
www.vEmployee.com
Reply With Quote
  #3 (permalink)  
Old 10-05-07, 08:55
mvreade mvreade is offline
Registered User
 
Join Date: Sep 2006
Posts: 19
Thanks, Swapnil (again coming to the rescue)...

Comparing this Update with the one you posted two days ago (http://www.dbforums.com/showthread.php?t=1622982), I'm not sure why the other one required a subquery and this one doesn't...

If you could please clarify that for me I'd be most thankful.

All the best,

mvreade
Reply With Quote
  #4 (permalink)  
Old 10-05-07, 10:21
swapnilclarion swapnilclarion is offline
Registered User
 
Join Date: May 2007
Posts: 8
In my earlier reply for thread 1622982,

We need to calculate SUM (For this we have used inner query) and then update respective table.

However,

In current post we just need to update respective table checking related ID's in two different table.

So Inner query was used specifically for calculating SUM.

Thanks,
__________________
Swapnil Patil
DB Team @ Clarion
Clarion Technologies
(SEI CMMI Level 3)
Pune, India
www.clariontechnologies.co.in
www.vEmployee.com
Reply With Quote
  #5 (permalink)  
Old 10-06-07, 01:19
mvreade mvreade is offline
Registered User
 
Join Date: Sep 2006
Posts: 19
Thanks for the clarification, Swapnil.

All the best,

Michael Reade
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

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