Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MYSQL update query

Posted on 2014-01-27
5
Medium Priority
?
447 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 800 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 41

Accepted Solution

by:
Sharath earned 1200 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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
In this article, we’ll look at how to deploy ProxySQL.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

721 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