SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard WorldNews's Avatar
    Join Date
    Nov 2007
    Posts
    1,027
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    How do I delete the content of 1 Table but look at 2 Tables

    Hello,

    How do I delete the content of 1 Table but look at 2 Tables to generate the list of rows that should be deleted.
    For example, say this is the SELECT command:

    Code MySQL:
    select user_id, advertising_amount FROM users, payments
    WHERE users.id = payments.user_id
    AND click = 'yes'
    AND vs_respmessage = 'Deducted';


    How do I then DELETE the resulting ROWS which belong to one of these Tables. That is I need to look at the Table users and Table payments, but DELETE from Table payments only.

    Regards,

    Anoox search engine volunteer

    www.anoox.com

  2. #2
    SitePoint Member Mez's Avatar
    Join Date
    Mar 2008
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    DELETE p
    FROM users u, payments p
    WHERE u.id = p.user_id
    AND click = 'yes'
    AND vs_respmessage = 'Deducted';

  3. #3
    SitePoint Wizard WorldNews's Avatar
    Join Date
    Nov 2007
    Posts
    1,027
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    This works fine.
    Thank you

    Quote Originally Posted by Mez View Post
    Code:
    DELETE p
    FROM users u, payments p
    WHERE u.id = p.user_id
    AND click = 'yes'
    AND vs_respmessage = 'Deducted';

    Anoox search engine volunteer

    www.anoox.com


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
  •