delete query not work???????????

Discussion in 'PHP' started by dineshsingh1984, Sep 22, 2014.

  1. #1
    it's my delete query
    delete from test where id in (select id from test where id not in (select id from test group by name order by id asc))

    this query not work but in this query
    select id from test where id not in (select id from test group by name order by id asc)
    work correct.
    plz tell me what the problem in delete query............
     
    dineshsingh1984, Sep 22, 2014 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,895
    Likes Received:
    4,553
    Best Answers:
    123
    Trophy Points:
    665
    #2
    I don't even see how your select works given that you are trying to select the id from a table where the id doesn't appear in the table.

    Now if your query was

    select id from tableA where id not in (select id from tableB)

    that would make sense - and in your subquery you don't need to group, order etc - just make sure the indexes are right.

    So your delete could be

    delete from tableA where id not in (select id from tableB)

    but backup first!
     
    sarahk, Sep 22, 2014 IP
  3. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #3
    What I'm wondering is how people manage to find the "color my text"-button, but not the CODE-button?
     
    PoPSiCLe, Sep 22, 2014 IP
    MrPJH, qwikad.com and sarahk like this.
  4. YoGem

    YoGem Active Member

    Messages:
    676
    Likes Received:
    8
    Best Answers:
    2
    Trophy Points:
    90
    #4
    @PoPSiCLe because there is also people who use "comic sans serif" to write articles and news and people lazy at typing [ code ][ /code ].
     
    YoGem, Sep 22, 2014 IP
  5. sarahk

    sarahk iTamer Staff

    Messages:
    28,895
    Likes Received:
    4,553
    Best Answers:
    123
    Trophy Points:
    665
    #5
    It's not wildly intuitive
    upload_2014-9-23_9-22-22.png
     
    sarahk, Sep 22, 2014 IP
  6. YoGem

    YoGem Active Member

    Messages:
    676
    Likes Received:
    8
    Best Answers:
    2
    Trophy Points:
    90
    #6
    But yet, you can type it! :)
     
    YoGem, Sep 22, 2014 IP
  7. sarahk

    sarahk iTamer Staff

    Messages:
    28,895
    Likes Received:
    4,553
    Best Answers:
    123
    Trophy Points:
    665
    #7
    If you are savvy enough to know about bbcode. Given the query this guy was trying to hack together I'm wouldn't assume he knew.
     
    sarahk, Sep 22, 2014 IP
  8. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #8
    Well, granted, a site like this might consider adding a separate [ code ]-button to the main menu on the editor, but still...
     
    PoPSiCLe, Sep 23, 2014 IP