SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict Phil-man's Avatar
    Join Date
    Nov 2000
    Posts
    291
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can I "Relate" Tables in a DELETE Query?

    Hi:

    Is there any reason why I can't do a query like the following...

    DELETE FROM Stats, Domains WHERE Save='N' AND Flag='Y' AND DID=Domains.ID

    (assume that "Save" and "DID" are fields in the Stats table and "Flag" is a field in the Domains table)

    In other words, I only want to delete entries from the Stats table, but I need to use a field in the Domains table to qualify it. Will this work all right?

    Thanks.

  2. #2
    SitePoint Addict Viral's Avatar
    Join Date
    Nov 2001
    Location
    Washington DC
    Posts
    294
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in mysql 4.0+ you can do multitable DELETEs (even to delete from a single table based on multiple table joins, as you need), but the format is a little different than you have here. See http://www.mysql.com/doc/en/DELETE.html for more info. I don't think it's possible to use joins in mysql 3.x but I could be wrong...(?)

    --Viral
    A computer without Windows is like a chocolate cake without mustard.


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
  •