SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict bronze trophy
    Join Date
    Sep 2005
    Posts
    323
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)

    Deleting with INNER JOIN

    So I have this query:

    Code:
    DELETE inventory.* FROM `inventory` INNER JOIN item_instances ON item_instances.ID = inventory.instanceid
    			   WHERE inventory.userid = '{$this->info['id']}' AND item_instances.itemid = '$itemid'
    This works fine- the only problem is I want it to delete ONE row, but instead it deletes all rows matching the "where". I tried adding LIMIT 1 but I get mysql error.

    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 1' at line 2

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,509
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    What difference is there between the row you want to delete and the other rows? Put that unique feature in the WHERE condition.

  3. #3
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You can't use LIMIT with a multi-table DELETE. Find another way to identify the rows you want to delete.


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
  •