MySQL Database problem...please help

Discussion in 'MySQL' started by Cheap SEO Services, Jul 2, 2008.

Thread Status:
Not open for further replies.
  1. #1
    Hi,

    I am running MySql version 5.0.51a in PHPMyAdmin. There is a table with over 900 items in it.

    Let's call this table item_cost

    One of the fields is called cost_value

    What I want to do is find all the records where the cost_value = 0.11 and update all records so the price changes to 0.08

    Anyone know how to structure the query statement to do this?

    When I browse the table a SQL Query shows this:

    SQL query:
    SELECT *
    FROM `item_cost`
    LIMIT 0 , 500

    I guess I would need to edit this query to not only find all the records equalling 0.11 but also edit them all to 0.08

    Thanks for any help.

    Col :)
     
    Cheap SEO Services, Jul 2, 2008 IP
  2. Dondon2d

    Dondon2d Peon

    Messages:
    3,193
    Likes Received:
    146
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Something like this line of query should help you Col:

    UPDATE `item_cost` SET `cost_value` = '0.08' WHERE `cost_value` = '0.11'
    Code (markup):
     
    Dondon2d, Jul 2, 2008 IP
    Cheap SEO Services likes this.
  3. kmofo

    kmofo Active Member

    Messages:
    442
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    85
    #3
    UPDATE item_cost
    SET cost_value= 0.08
    WHERE cost_value= 0.11

    that should be it!
     
    kmofo, Jul 2, 2008 IP
  4. Cheap SEO Services

    Cheap SEO Services <------DoFollow Backlinks

    Messages:
    16,664
    Likes Received:
    1,318
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Oh you DA MAN!!!! That worked perfectly...thanks buddy!

    Co :)
     
    Cheap SEO Services, Jul 2, 2008 IP
  5. Dondon2d

    Dondon2d Peon

    Messages:
    3,193
    Likes Received:
    146
    Best Answers:
    0
    Trophy Points:
    0
    #5
    No problem Col :)
     
    Dondon2d, Jul 2, 2008 IP
  6. WebLOADER

    WebLOADER Well-Known Member

    Messages:
    118
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #6
    UPDATE `item_cost` SET `cost_value` = '0.08' WHERE `cost_value` = '0.11'
     
    WebLOADER, Jul 2, 2008 IP
  7. Cheap SEO Services

    Cheap SEO Services <------DoFollow Backlinks

    Messages:
    16,664
    Likes Received:
    1,318
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Thanks for all you guys help...I have a new question:

    If I have 2 databases and I want to copy some tables from one db to the other...how can this be done using a sql statement?
     
    Cheap SEO Services, Jul 16, 2008 IP
  8. Dondon2d

    Dondon2d Peon

    Messages:
    3,193
    Likes Received:
    146
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I think it's much easier if you do it manually Col or you can do it like this:

    USE db2;
    
    CREATE TABLE table2 LIKE db1.table1;
    
    INSERT INTO table2  
       SELECT * FROM db1.table1;
    Code (markup):
    Not sure though :D
     
    Dondon2d, Jul 16, 2008 IP
  9. Cheap SEO Services

    Cheap SEO Services <------DoFollow Backlinks

    Messages:
    16,664
    Likes Received:
    1,318
    Best Answers:
    0
    Trophy Points:
    0
    #9

    This didn't work. All I got was:

    SQL query:

    USE db2;

    MySQL said: Documentation
    #1044 - Access denied for user 'db1'@'localhost' to database 'db2'
     
    Cheap SEO Services, Jul 18, 2008 IP
  10. kmofo

    kmofo Active Member

    Messages:
    442
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    85
    #10
    you need to assign the same user to both databases and grant privileges. add user db1@localhost to db2.
     
    kmofo, Jul 19, 2008 IP
  11. Cheap SEO Services

    Cheap SEO Services <------DoFollow Backlinks

    Messages:
    16,664
    Likes Received:
    1,318
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Done that...still no go.
     
    Cheap SEO Services, Jul 20, 2008 IP
  12. Cheap SEO Services

    Cheap SEO Services <------DoFollow Backlinks

    Messages:
    16,664
    Likes Received:
    1,318
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Maybe someone can login and try for me?
     
    Cheap SEO Services, Jul 21, 2008 IP
  13. llamafier

    llamafier Peon

    Messages:
    388
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #13
    I think you could probably download a backup type thing of the table and then upload it into the other database. Not sure about using a SQL statement though.
     
    llamafier, Jul 21, 2008 IP
  14. Cheap SEO Services

    Cheap SEO Services <------DoFollow Backlinks

    Messages:
    16,664
    Likes Received:
    1,318
    Best Answers:
    0
    Trophy Points:
    0
    #14
    OK...This is what I did. Performed a backup of the database. Reinstalled the vBulletin. Then tried to import the database and this is what I come up with:

    Why won't this work?

    EDIT: OK...it worked partially. I got the stats to show so many threads, posts and users...but not the number of forums and the threads are not displaying either....GRRRRRR
     

    Attached Files:

    Cheap SEO Services, Jul 21, 2008 IP
  15. Dondon2d

    Dondon2d Peon

    Messages:
    3,193
    Likes Received:
    146
    Best Answers:
    0
    Trophy Points:
    0
    #15
    Maybe it's not the only table that was needed.
     
    Dondon2d, Jul 21, 2008 IP
  16. Cheap SEO Services

    Cheap SEO Services <------DoFollow Backlinks

    Messages:
    16,664
    Likes Received:
    1,318
    Best Answers:
    0
    Trophy Points:
    0
    #16
    Looks like I got it sorted.

    Thanks for your help.

    Col :)
     
    Cheap SEO Services, Jul 21, 2008 IP
Thread Status:
Not open for further replies.