Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2011
    Posts
    3

    Unanswered: Merging mysql queries or running them in one attempt

    I have these two queries which i want to run together and not one by one. How can i do that? Or can it be modified to be one query.

    Code:
    UPDATE runquery.table1, runquery.table2 SET runquery.table1.`Column1` = (runquery.table2.`Col1`/runquery.table2.`Col2`*100) WHERE runquery.table2.`itemid` = 3 AND runquery.table1.`Userids` = runquery.table2.`userid`;
    UPDATE runquery.table1, runquery.table2 SET runquery.table1.`Column2` = (runquery.table2.`Col1`/runquery.table2.`Col2`*100) WHERE runquery.table2.`itemid` = 5 AND runquery.table1.`Userids` = runquery.table2.`userid`;

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    can't be done in one, was already tried here

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Apr 2011
    Posts
    3
    how about using UNION? Or may be modify it by using INSERT INTO ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •