How do i join 2 different queries (select and update in MySql)

Discussion in 'MySQL' started by webdezzi, Jul 5, 2007.

  1. #1
    Can anyone help with sample of joining a select query with an update query
    i tried using UNION and UNION ALL but it keeps telling me to check my syntax


    Invalid query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE pages SET id=

    this is the query
    select * from pages where id="206" UNION ALL UPDATE pages SET id="999" where id="164"

    id column is varchar
     
    webdezzi, Jul 5, 2007 IP
  2. turiel

    turiel Peon

    Messages:
    148
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I don't think you can do that, and I don't see why you would need to. Your queries don't even seem related, why don't you do seperate ones?
     
    turiel, Jul 5, 2007 IP
  3. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,680
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #3
    if it is just two unconnected queries then you simply separate them with a ;

    select * from pages where id="206"; UPDATE pages SET id="999" where id="164"
     
    AstarothSolutions, Jul 5, 2007 IP