Greenguy's Board


Go Back   Greenguy's Board > Programming & Scripting
Register FAQ Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 2004-03-14, 07:18 AM   #1
xsiteu
WHO IS FONZY!?! Don't they teach you anything at school?
 
Join Date: Feb 2004
Location: Cyberspace
Posts: 40
Send a message via ICQ to xsiteu
Removing rows from table

Any SQL people out there can proably answer this in a few seconds.

I want to remove rows from a table that are older than a certain date.

I am OK building all sorts of select statements but not one for a date range. Part of the problem is probably that this is just a char field and not a date field so cannot to date arithmetic on it.

In fact I would be happy just to delete all record containing "2003"

I have tried the following:

SELECT * FROM `tblTgp` WHERE `date` LIKE '2003%'

will return the rows I would like to delete but

DELETE * FROM `tblTgp` WHERE `date` LIKE '2003%'

results in an error

Here is the table structure but the only item of interest is probably just the date field:

id int(11) No auto_increment
nickname char(30) No
email char(100) No
url char(150) No
category char(100) No
description char(100) No
date char(8) No
newpost char(10) No yes
accept char(10) No
vote int(3) No 5
recip char(5) No
sessionid char(45) No

Here is a typical data field entry

20031224

Using My PHP (Unix)
__________________
<a href=http://www.xsiteu.com>XsiteU Adult Links</A>
<a href=http://www.honeybabes.net>Honeybabes TGP</A>
<a href=http://www.cumfacts.com>CUM fACTS</A>
xsiteu is offline   Reply With Quote
Old 2004-03-14, 03:17 PM   #2
Entreri
WHO IS FONZY!?! Don't they teach you anything at school?
 
Join Date: Feb 2004
Posts: 42
Re: Removing rows from table

Quote:
Originally posted by xsiteu
I have tried the following:

SELECT * FROM `tblTgp` WHERE `date` LIKE '2003%'

will return the rows I would like to delete but

DELETE * FROM `tblTgp` WHERE `date` LIKE '2003%'
DELETE tblTgp WHERE date LIKE '2003%'

Entreri.
Entreri is offline   Reply With Quote
Old 2004-03-14, 04:01 PM   #3
xsiteu
WHO IS FONZY!?! Don't they teach you anything at school?
 
Join Date: Feb 2004
Location: Cyberspace
Posts: 40
Send a message via ICQ to xsiteu
Entreri,

Thanks for the suggestion but no luck

Result:

Quote:
Error

SQL-query :

DELETE tblTgp WHERE date LIKE '2003%'

MySQL said:


#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 'WHERE date LIKE '2003%'' at line 1

[Documentation] · [Back]
__________________
<a href=http://www.xsiteu.com>XsiteU Adult Links</A>
<a href=http://www.honeybabes.net>Honeybabes TGP</A>
<a href=http://www.cumfacts.com>CUM fACTS</A>
xsiteu is offline   Reply With Quote
Old 2004-03-14, 04:27 PM   #4
Entreri
WHO IS FONZY!?! Don't they teach you anything at school?
 
Join Date: Feb 2004
Posts: 42
Quote:
Originally posted by xsiteu
Entreri,

Thanks for the suggestion but no luck

Result:
Okay, perhaps mysql is stricter on the query. (I usually use ms-sql)

Try this :

DELETE FROM tblTgp WHERE date LIKE '2003%'

Alas, I'm leaving to see WrestleMania XX at a movie theater shortly so I cannot help further right now.

Entreri.

ps. See mysql doc if it still doesn't work. http://www.mysql.com/doc/en/DELETE.html
Entreri is offline   Reply With Quote
Old 2004-03-14, 06:34 PM   #5
xsiteu
WHO IS FONZY!?! Don't they teach you anything at school?
 
Join Date: Feb 2004
Location: Cyberspace
Posts: 40
Send a message via ICQ to xsiteu
That did the trick.

Thanks heaps and I hope you enjoy WrestleMania XX

Ralph.
__________________
<a href=http://www.xsiteu.com>XsiteU Adult Links</A>
<a href=http://www.honeybabes.net>Honeybabes TGP</A>
<a href=http://www.cumfacts.com>CUM fACTS</A>
xsiteu is offline   Reply With Quote
Reply


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 -4. The time now is 02:04 PM.


Mark Read
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc