Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-26-2012, 07:59 PM   PM User | #1
sonny
Regular Coder

 
sonny's Avatar
 
Join Date: Apr 2008
Location: United States
Posts: 567
Thanks: 88
Thanked 0 Times in 0 Posts
sonny can only hope to improve
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 08:55 PM..
sonny is offline   Reply With Quote
Old 04-26-2012, 08:11 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,748
Thanks: 4
Thanked 2,466 Times in 2,435 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
There's no AND condition in there.
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
sonny (04-26-2012)
Old 04-26-2012, 08:35 PM   PM User | #3
sonny
Regular Coder

 
sonny's Avatar
 
Join Date: Apr 2008
Location: United States
Posts: 567
Thanks: 88
Thanked 0 Times in 0 Posts
sonny can only hope to improve
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 08:49 PM..
sonny is offline   Reply With Quote
Old 04-26-2012, 08:43 PM   PM User | #4
guelphdad
Super Moderator


 
guelphdad's Avatar
 
Join Date: Mar 2006
Location: St. Catharines, Ontario Canada
Posts: 2,629
Thanks: 4
Thanked 147 Times in 138 Posts
guelphdad will become famous soon enoughguelphdad will become famous soon enough
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.
guelphdad is offline   Reply With Quote
Users who have thanked guelphdad for this post:
sonny (04-26-2012)
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:40 PM.


Advertisement
Log in to turn off these ads.