Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder sonny's Avatar
    Join Date
    Apr 2008
    Location
    United States
    Posts
    567
    Thanks
    88
    Thanked 0 Times in 0 Posts

    delete entry, but with exception php mysql

    Hi

    I am trying to delete all entry's before a certain date, "except those matching testfolder"
    this should work I think, anyone see why it doesn't? it deletes everything.

    My php form's query
    PHP Code:
    $sql "DELETE FROM `$tbl` WHERE `$field` < '$before' NOT LIKE url='%/testfolder/%"
    Thanks
    Sonny
    Last edited by sonny; 04-26-2012 at 09:55 PM.

  2. #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    17,027
    Thanks
    4
    Thanked 2,668 Times in 2,637 Posts
    There's no AND condition in there.

  3. Users who have thanked Fou-Lu for this post:

    sonny (04-26-2012)

  4. #3
    Regular Coder sonny's Avatar
    Join Date
    Apr 2008
    Location
    United States
    Posts
    567
    Thanks
    88
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    There's no AND condition in there.
    PHP Code:
    $sql "DELETE FROM `$tbl` WHERE `$field` < '$before' AND url NOT LIKE '%/testfolder/%"
    works now

    Thanks
    Sonny
    Last edited by sonny; 04-26-2012 at 09:49 PM.

  5. #4
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,659
    Thanks
    6
    Thanked 150 Times in 141 Posts
    well yes you would.

    You are basically saying:

    select * from cars where color='black' and 'four'

    you want

    select * from cars where color='black' and wheels='four'

    you have to specify which field you are checking after the AND, which you have not done above.

  6. Users who have thanked guelphdad for this post:

    sonny (04-26-2012)


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •