www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Server-Side Development > SQL

    SQL For all Structured Query Language, and general database questions.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 11-06-2009, 06:48 AM
    dai.hop dai.hop is offline
    Registered User
     
    Join Date: Aug 2006
    Posts: 120
    Update on 80% of Records

    Hi all,

    I have a table presently containing 40,905 rows. I would like to run a query that will update the 'marker' field on 80% of these records. Something like...

    Code:
    UPDATE comments SET marker = 'Foo' WHERE id IN (SELECT RANDOM 80% FROM comments)
    Is this possible? If so, is it possible to do without crippling the database server?

    Thanks!

    dai.hop
    Reply With Quote
      #2  
    Old 11-06-2009, 12:41 PM
    ssystems ssystems is offline
    Registered User
     
    Join Date: Oct 2009
    Posts: 223
    Whan database are you using? 40k rows is nothing unless each row is 1GB each.
    __________________
    Good Luck

    Santos Systems
    Reply With Quote
      #3  
    Old 11-06-2009, 01:35 PM
    dai.hop dai.hop is offline
    Registered User
     
    Join Date: Aug 2006
    Posts: 120
    It's MySQL version 4.1.11
    Reply With Quote
      #4  
    Old 11-06-2009, 01:43 PM
    ssystems ssystems is offline
    Registered User
     
    Join Date: Oct 2009
    Posts: 223
    Ugggh. Don't you think its time to upgrade?

    Here is on MSSQL
    Code:
    update comments set marker = 'foo' where id in (select top (FLOOR(4 * (SELECT COUNT(*) FROM comments ) / 5)) id from comments ORDER BY NEWID())
    I think you can do something similar to that in 5.0.7 using Prepare. Check the concept and just translate it to the syntax of your database.
    __________________
    Good Luck

    Santos Systems
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 08:49 AM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.