How to turn SELECT statement into a DELETE statement I'm trying to turn this select statement into a delete statement and I'm struggling to not delete all the records in the table.  Here is the SQL select statement I'm using

SELECT  *
    FROM  message_cus_board mcb
    WHERE  mcb.board_id IN (
        SELECT  mb.board_id
            FROM  message_boards mb
            WHERE  mb.customer_id = :customerid
              AND  mb.universal_board = 'Y'
                          )
    ORDER BY  mcb.created_on DESC"


This queries all of the messages from the message_cus_board table and basically I want to delete all of the messages this would normally display except the last 15.  One thing I've tried is taking all of those message_id's and making an array of the most recent 15 then creating a delete statement with those id's like so -> 

"DELETE FROM message_cus_board WHERE message_id NOT IN ($string_of_ids)"


The only issue is that this delete query gets rid of ALL other messages, not just the ones associated with the right customer.  I'm struggling to create a delete query that limits the delete to the right customer using similar logic to the select statement above.  I'm sure it's a fairly simple solution but it's currently eluding me.  Thanks for any help!
You can just use the select statement in the where clause and just select for the element you are matching on

DELETE FROM message_cus_board 
WHERE message_id NOT IN (
    SELECT message_id 
    FROM message_cus_board mcb
    WHERE mcb.board_id IN 
        (SELECT mb.board_id 
         FROM message_boards mb 
         WHERE mb.customer_id = :customerid 
         AND mb.universal_board = 'Y'))