SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: mysql fastest queries

  1. #1
    SitePoint Zealot
    Join Date
    Nov 2005
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mysql fastest queries

    [not sure if this the correct category to post]

    although there are some solutions for this...
    what is, in your opinion, the fastest queries for this?...

    C1 | C2 | C3 | C4
    ------------------
    AA | BB | XX | XX
    A1 | B1 | 12 | 34
    A2 | B2 | XX | XX

    When C3 and C4 = XX, UPDATE C3 = C1 AND C4 = C2

    C1 | C2 | C3 | C4
    ------------------
    AA | BB | AA | BB
    A1 | B1 | 12 | 34
    A2 | B2 | A2 | B2

  2. #2
    SQL Consultant silver trophybronze trophy
    SitePoint Award Recipient r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    38,457
    Mentioned
    34 Post(s)
    Tagged
    1 Thread(s)
    the fastest query is
    Code:
    UPDATE daTable
       SET c3 = c1 
         , c4 = c2
     WHERE c3 = 'XX'
       AND c4 = 'XX'
    i know it's the fastest because it's also the only way to do it
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

Bookmarks

Posting Permissions

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