SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Jan 2006
    Posts
    169
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Multi table delete query not working

    The following query isn't working for me. Can someone tell me what I'm doing wrong:

    Code:
    DELETE FROM 
      gs_shipments AS s,
      gs_waypoints AS w 
    WHERE 
      s.tracking_number =  '157026850207366' 
      AND s.is_offset =0 
      AND s.shipment_id = w.shipment_id 
      AND s.user_id =119

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Refer to the multi-table DELETE syntax in the manual:

    http://dev.mysql.com/doc/refman/5.0/en/delete.html

    You need to specify which table's rows you want to delete before the FROM clause.

  3. #3
    SitePoint Zealot
    Join Date
    Jan 2006
    Posts
    169
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Does this mean:

    Code:
    DELETE 
      s,
      w
    FROM 
      gs_shipments AS s,
      gs_waypoints AS w 
    WHERE 
      s.tracking_number =  '157026850207366' 
      AND s.is_offset =0 
      AND s.shipment_id = w.shipment_id 
      AND s.user_id =119
    is the right syntax?

  4. #4
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    If you want to delete all rows in tables s and w matching those conditions


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
  •