SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Feb 2004
    Location
    Netherlands
    Posts
    381
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Rewrite mysql 5 query to v.4

    Hi,

    I've got this query:
    Code:
     DELETE FROM `scms_profiles_log`
     WHERE `pID` = '938' 
    AND `ID` NOT IN (SELECT * FROM (SELECT `ID` FROM `scms_profiles_log` 
    WHERE `pID` = '938' 
    ORDER BY `ID` 
    DESC LIMIT 4) AS TAB)
    How can I make this work in mysql 4?

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,246
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    do it with 2 queries -- the first to return the 4 ids, and the second to delete the rows that aren't one of those 4
    rudy.ca | @rudydotca
    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
  •