Delete Query

This is a discussion on Delete Query within the MySQL Database forums, part of the Database Forums category; I am trying to run the MySQL delete query in phpMyAdmin, now the query runs and doesn't give any ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-26-2008
trawets
 
Posts: n/a
Default Delete Query

I am trying to run the MySQL delete query in phpMyAdmin, now the query
runs and doesn't give any syntax errors, but it also doesn't delete
and rows

From the query you can see the table name (jos_content) and two
fields, state (-1 = unpublished) and publish_down,

DELETE FROM jos_content WHERE state=-1 AND DATE_ADD(publish_down,
INTERVAL '90' DAY) = CURRENT_DATE

so what I am trying to achieve is that any entries that are not
published and and its been 90 days since they were unpublished I would
like to delete them, but as I say it runs but does not delete any
entries so I'm guessing that there is something wrong with interval
part
any suggestions please
Reply With Quote
  #2 (permalink)  
Old 03-26-2008
Richard
 
Posts: n/a
Default Re: Delete Query


"trawets" <stewartrsmith@gmail.com> wrote in message
news:cf034d87-f6f8-4f63-931d-d1d016406d0f@d21g2000prf.googlegroups.com...
>I am trying to run the MySQL delete query in phpMyAdmin, now the
>query
> runs and doesn't give any syntax errors, but it also doesn't delete
> and rows
>
> From the query you can see the table name (jos_content) and two
> fields, state (-1 = unpublished) and publish_down,
>
> DELETE FROM jos_content WHERE state=-1 AND DATE_ADD(publish_down,
> INTERVAL '90' DAY) = CURRENT_DATE
>
> so what I am trying to achieve is that any entries that are not
> published and and its been 90 days since they were unpublished I
> would
> like to delete them, but as I say it runs but does not delete any
> entries so I'm guessing that there is something wrong with interval
> part
> any suggestions please


What do you get as results when you do the same selection in a select
statement?

SELECT * FROM jos_content WHERE state=-1 AND DATE_ADD(publish_down,
INTERVAL '90' DAY) = CURRENT_DATE

'90' ? Sure a text value? Not a numeric value there?

R.


Reply With Quote
  #3 (permalink)  
Old 03-26-2008
trawets
 
Posts: n/a
Default Re: Delete Query

On Mar 26, 8:35*pm, "Richard" <root@localhost> wrote:
> "trawets" <stewartrsm...@gmail.com> wrote in message
>
> news:cf034d87-f6f8-4f63-931d-d1d016406d0f@d21g2000prf.googlegroups.com...
>
>
>
>
>
> >I am trying to run the MySQL delete query in phpMyAdmin, now the
> >query
> > runs and doesn't give any syntax errors, but it also doesn't delete
> > and rows

>
> > From the query you can see the table name (jos_content) and two
> > fields, state (-1 = unpublished) and publish_down,

>
> > DELETE FROM jos_content WHERE state=-1 AND DATE_ADD(publish_down,
> > INTERVAL '90' DAY) = CURRENT_DATE

>
> > so what I am trying to achieve is that any entries that are not
> > published and and its been 90 days since they were unpublished I
> > would
> > like to delete them, but as I say it runs but does not delete any
> > entries so I'm guessing that there is something wrong with interval
> > part
> > any suggestions please

>
> What do you get as results when you do the same selection in a select
> statement?
>
> SELECT * FROM jos_content WHERE state=-1 AND DATE_ADD(publish_down,
> INTERVAL '90' DAY) = CURRENT_DATE
>
> '90' ? Sure a text value? Not a numeric value there?
>
> R.- Hide quoted text -
>
> - Show quoted text -


Hi
Thanks for replying

resuts of query
MySQL returned an empty result set (i.e. zero rows).

SQL query:
SELECT *
FROM jos_content
WHERE state = -1
AND DATE_ADD( publish_down, INTERVAL '90'
DAY ) = CURRENT_DATE
LIMIT 0 , 30

Im not sure what you mean by this
" '90' ? Sure a text value? Not a numeric value there?"

when I run the query for state only I get
21,705 rows where most of these have been unpulished for 90 days or
more
Reply With Quote
  #4 (permalink)  
Old 03-26-2008
Peter H. Coffin
 
Posts: n/a
Default Re: Delete Query

On Wed, 26 Mar 2008 13:46:22 -0700 (PDT), trawets wrote:
> On Mar 26, 8:35*pm, "Richard" <root@localhost> wrote:
>> "trawets" <stewartrsm...@gmail.com> wrote in message
>>
>> news:cf034d87-f6f8-4f63-931d-d1d016406d0f@d21g2000prf.googlegroups.com...
>>
>>
>>
>>
>>
>> >I am trying to run the MySQL delete query in phpMyAdmin, now the
>> >query
>> > runs and doesn't give any syntax errors, but it also doesn't delete
>> > and rows

>>
>> > From the query you can see the table name (jos_content) and two
>> > fields, state (-1 = unpublished) and publish_down,

>>
>> > DELETE FROM jos_content WHERE state=-1 AND DATE_ADD(publish_down,
>> > INTERVAL '90' DAY) = CURRENT_DATE

>>
>> > so what I am trying to achieve is that any entries that are not
>> > published and and its been 90 days since they were unpublished I
>> > would
>> > like to delete them, but as I say it runs but does not delete any
>> > entries so I'm guessing that there is something wrong with interval
>> > part
>> > any suggestions please

>>
>> What do you get as results when you do the same selection in a select
>> statement?
>>
>> SELECT * FROM jos_content WHERE state=-1 AND DATE_ADD(publish_down,
>> INTERVAL '90' DAY) = CURRENT_DATE
>>
>> '90' ? Sure a text value? Not a numeric value there?
>>
>> R.- Hide quoted text -
>>
>> - Show quoted text -

>
> Hi
> Thanks for replying
>
> resuts of query
> MySQL returned an empty result set (i.e. zero rows).
>
> SQL query:
> SELECT *
> FROM jos_content
> WHERE state = -1
> AND DATE_ADD( publish_down, INTERVAL '90'
> DAY ) = CURRENT_DATE
> LIMIT 0 , 30
>
> Im not sure what you mean by this
> " '90' ? Sure a text value? Not a numeric value there?"
>
> when I run the query for state only I get
> 21,705 rows where most of these have been unpulished for 90 days or
> more


You are not asking for "or more" in your query. You are asking for
*exactly* 90 days. And be careful when changing that equals sign. It'll
be backawards from what you may want to use at first.

--
Cunningham's First Law:
Any sufficiently complex deterministic system will exhibit
non-deterministic behaviour.
Reply With Quote
  #5 (permalink)  
Old 03-26-2008
Mark Huizer
 
Posts: n/a
Default Re: Delete Query

> SQL query:
> SELECT *
> FROM jos_content
> WHERE state = -1
> AND DATE_ADD( publish_down, INTERVAL '90'
> DAY ) = CURRENT_DATE
> LIMIT 0 , 30
>
> when I run the query for state only I get
> 21,705 rows where most of these have been unpulished for 90 days or
> more


I think 'or more' is the importnt thing here. You look for rows
_exactly_ 90 days ago.

mark

--
Terantula - Industrial Strength Open Source - http://www.terantula.com/
Projects and administration - +31 6 5140 5160
Reply With Quote
  #6 (permalink)  
Old 03-26-2008
trawets
 
Posts: n/a
Default Re: Delete Query

On Mar 26, 9:08*pm, "Peter H. Coffin" <hell...@ninehells.com> wrote:
> On Wed, 26 Mar 2008 13:46:22 -0700 (PDT), trawets wrote:
> > On Mar 26, 8:35*pm, "Richard" <root@localhost> wrote:
> >> "trawets" <stewartrsm...@gmail.com> wrote in message

>
> >>news:cf034d87-f6f8-4f63-931d-d1d016406d0f@d21g2000prf.googlegroups.com....

>
> >> >I am trying to run the MySQL delete query in phpMyAdmin, now the
> >> >query
> >> > runs and doesn't give any syntax errors, but it also doesn't delete
> >> > and rows

>
> >> > From the query you can see the table name (jos_content) and two
> >> > fields, state (-1 = unpublished) and publish_down,

>
> >> > DELETE FROM jos_content WHERE state=-1 AND DATE_ADD(publish_down,
> >> > INTERVAL '90' DAY) = CURRENT_DATE

>
> >> > so what I am trying to achieve is that any entries that are not
> >> > published and and its been 90 days since they were unpublished I
> >> > would
> >> > like to delete them, but as I say it runs but does not delete any
> >> > entries so I'm guessing that there is something wrong with interval
> >> > part
> >> > any suggestions please

>
> >> What do you get as results when you do the same selection in a select
> >> statement?

>
> >> SELECT * FROM jos_content WHERE state=-1 AND DATE_ADD(publish_down,
> >> INTERVAL '90' DAY) = CURRENT_DATE

>
> >> '90' ? Sure a text value? Not a numeric value there?

>
> >> R.- Hide quoted text -

>
> >> - Show quoted text -

>
> > Hi
> > Thanks for replying

>
> > resuts of query
> > MySQL returned an empty result set (i.e. zero rows).

>
> > *SQL query:
> > SELECT *
> > FROM jos_content
> > WHERE state = -1
> > AND DATE_ADD( publish_down, INTERVAL '90'
> > DAY ) = CURRENT_DATE
> > LIMIT 0 , 30

>
> > Im not sure what you mean by this
> > " '90' ? Sure a text value? Not a numeric value there?"

>
> > when I run the query for state only I get
> > 21,705 rows where most of these have been unpulished for 90 days or
> > more

>
> You are not asking for "or more" in your query. You are asking for
> *exactly* 90 days. And be careful when changing that equals sign. It'll
> be backawards from what you may want to use at first.
>
> --
> Cunningham's First Law:
> Any sufficiently complex deterministic system will exhibit
> non-deterministic behaviour.- Hide quoted text -
>
> - Show quoted text -


I get what you mean now
when I add the <> operators to the select query I get records,
some 8000 for > and 15000 for < ,
so your very right I need to be careful,
this is a bit spooky
Reply With Quote
  #7 (permalink)  
Old 03-26-2008
trawets
 
Posts: n/a
Default Re: Delete Query

On Mar 26, 9:43*pm, trawets <stewartrsm...@gmail.com> wrote:
> On Mar 26, 9:08*pm, "Peter H. Coffin" <hell...@ninehells.com> wrote:
>
>
>
>
>
> > On Wed, 26 Mar 2008 13:46:22 -0700 (PDT), trawets wrote:
> > > On Mar 26, 8:35*pm, "Richard" <root@localhost> wrote:
> > >> "trawets" <stewartrsm...@gmail.com> wrote in message

>
> > >>news:cf034d87-f6f8-4f63-931d-d1d016406d0f@d21g2000prf.googlegroups.com....

>
> > >> >I am trying to run the MySQL delete query in phpMyAdmin, now the
> > >> >query
> > >> > runs and doesn't give any syntax errors, but it also doesn't delete
> > >> > and rows

>
> > >> > From the query you can see the table name (jos_content) and two
> > >> > fields, state (-1 = unpublished) and publish_down,

>
> > >> > DELETE FROM jos_content WHERE state=-1 AND DATE_ADD(publish_down,
> > >> > INTERVAL '90' DAY) = CURRENT_DATE

>
> > >> > so what I am trying to achieve is that any entries that are not
> > >> > published and and its been 90 days since they were unpublished I
> > >> > would
> > >> > like to delete them, but as I say it runs but does not delete any
> > >> > entries so I'm guessing that there is something wrong with interval
> > >> > part
> > >> > any suggestions please

>
> > >> What do you get as results when you do the same selection in a select
> > >> statement?

>
> > >> SELECT * FROM jos_content WHERE state=-1 AND DATE_ADD(publish_down,
> > >> INTERVAL '90' DAY) = CURRENT_DATE

>
> > >> '90' ? Sure a text value? Not a numeric value there?

>
> > >> R.- Hide quoted text -

>
> > >> - Show quoted text -

>
> > > Hi
> > > Thanks for replying

>
> > > resuts of query
> > > MySQL returned an empty result set (i.e. zero rows).

>
> > > *SQL query:
> > > SELECT *
> > > FROM jos_content
> > > WHERE state = -1
> > > AND DATE_ADD( publish_down, INTERVAL '90'
> > > DAY ) = CURRENT_DATE
> > > LIMIT 0 , 30

>
> > > Im not sure what you mean by this
> > > " '90' ? Sure a text value? Not a numeric value there?"

>
> > > when I run the query for state only I get
> > > 21,705 rows where most of these have been unpulished for 90 days or
> > > more

>
> > You are not asking for "or more" in your query. You are asking for
> > *exactly* 90 days. And be careful when changing that equals sign. It'll
> > be backawards from what you may want to use at first.

>
> > --
> > Cunningham's First Law:
> > Any sufficiently complex deterministic system will exhibit
> > non-deterministic behaviour.- Hide quoted text -

>
> > - Show quoted text -

>
> I get what you mean now
> *when I add the <> operators to the select query I get records,
> *some 8000 for > and 15000 for < ,
> so your very right I need to be careful,
> *this is a bit spooky- Hide quoted text -
>
> - Show quoted text -


Hi Thanks to you all for helping out on this

this quer seems to work just fine

DELETE FROM jos_content WHERE state=-1 AND DATE_ADD(publish_down,
INTERVAL '90' DAY) <= CURRENT_DATE

I had to ensure it was the correct entries I wanted
Thanks again
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 04:33 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0