Solved

MYSQL update query

Posted on 2014-01-27
5
442 Views
Last Modified: 2014-01-30
MySQL UPDATE QUERY

hello I need help with an update query in MYSQL

I have 2 tables
c_item_property   (TABLE NAME)                             c_document  (TABLE Name
     c_id   int                                        1 to 1                      c_id    int
     ref   int                                          1 to 1                      id    int
     visibility    tinyint(4)                                                     path    varchar

ok... so between the 2 tables I need to update the c_item_property table
with the 1 to 1 relationship (i think it might be a join.. not sure) between c_id .....and the ref to id  1 to 1 relationship.

I need to update visibility to  1      when path =  '/week_03'

thanks for your help

FaithDan
0
Comment
Question by:FaithDan
  • 2
  • 2
5 Comments
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 200 total points
ID: 39813334
this article will explain how you need to write your UPDATE , though you must check out which syntax you need to pick for MySQL:
http://www.experts-exchange.com/Database/Miscellaneous/A_1517-UPDATES-with-JOIN-for-everybody.html
or directly the mysql reference for UPDATE:
http://dev.mysql.com/doc/refman/5.0/en/update.html
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 39813337
in code, it might be something like this  
UPDATE c_item_property   ip, c_document  c
  SET ip.visibility = 1
WHERE ip.id = c.id
  AND c.path =  '/week_03'

Open in new window

0
 
LVL 1

Author Comment

by:FaithDan
ID: 39813730
Hello .. I have it working as below in a select query..

what do I need to do to the code to change it to the update query.  I need to update ip.visibility to 1

SELECT ip.visibility, c.path
FROM c_item_property ip
join c_document c on ip.c_id = c.c_id
AND ip.ref = c.id and (ip.c_id = 62 or ip.c_id = 63 or ip.c_id = 64)

WHERE

 c.title LIKE 'week 03'
LIMIT 0 , 90
0
 
LVL 40

Accepted Solution

by:
Sharath earned 300 total points
ID: 39814291
check this.
UPDATE  c_item_property ip, c_document c
         SET  ip.visibility = 1
 WHERE ip.c_id = c.c_id
        AND ip.ref = c.id
        AND ip.c_id IN (62,63,64)
        AND c.title LIKE 'week 03’
    LIMIT 0,90

Open in new window

0
 
LVL 1

Author Closing Comment

by:FaithDan
ID: 39821495
Thank you very much.  This worked perfecly
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question