Beginner Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherBeginner Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 26th, 2003, 07:21 AM
clio clio is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Romania
Posts: 45 clio User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 26 m 8 sec
Reputation Power: 6
Send a message via Yahoo to clio
Question How to delete multiple rows

Hy ...
i have a table whith :
ID | Stuff
-------------
1 | First
2 | Second
3 | Third
.
.
.


I want to delete from a table 20 or 50 rows at once after the ID .
How can I do that ..???

THANX !!!
__________________
The future is on ... development .

Reply With Quote
  #2  
Old August 26th, 2003, 08:00 AM
ishnid's Avatar
ishnid ishnid is offline
kill 9, $$;
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Sep 2001
Location: Dublin, Eire
Posts: 5,651 ishnid User rank is General 7th Grade (Above 100000 Reputation Level)ishnid User rank is General 7th Grade (Above 100000 Reputation Level)ishnid User rank is General 7th Grade (Above 100000 Reputation Level)ishnid User rank is General 7th Grade (Above 100000 Reputation Level)ishnid User rank is General 7th Grade (Above 100000 Reputation Level)ishnid User rank is General 7th Grade (Above 100000 Reputation Level)ishnid User rank is General 7th Grade (Above 100000 Reputation Level)ishnid User rank is General 7th Grade (Above 100000 Reputation Level)ishnid User rank is General 7th Grade (Above 100000 Reputation Level)ishnid User rank is General 7th Grade (Above 100000 Reputation Level)ishnid User rank is General 7th Grade (Above 100000 Reputation Level)ishnid User rank is General 7th Grade (Above 100000 Reputation Level)ishnid User rank is General 7th Grade (Above 100000 Reputation Level)ishnid User rank is General 7th Grade (Above 100000 Reputation Level)ishnid User rank is General 7th Grade (Above 100000 Reputation Level)ishnid User rank is General 7th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 5 Days 20 h 15 m 3 sec
Reputation Power: 1432
You'll have to give more information than that. What type of database are you using? When you say '20 or 50 rows' are you trying to delete just the first 20/50 rows or are you trying to delete rows with specific IDs?

Reply With Quote
  #3  
Old August 26th, 2003, 08:10 AM
clio clio is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Romania
Posts: 45 clio User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 26 m 8 sec
Reputation Power: 6
Send a message via Yahoo to clio
Yes I want to delete with specific IDs like :
from 10 to 60 ..... or somwetring likke that ..

Reply With Quote
  #4  
Old August 26th, 2003, 08:25 AM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,840 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Days 36 m 16 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
delete from your_table where id between 10 and 60

Reply With Quote
  #5  
Old August 27th, 2003, 01:09 AM
clio clio is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Romania
Posts: 45 clio User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 26 m 8 sec
Reputation Power: 6
Send a message via Yahoo to clio
yes ... nice oane ,.,..thanks ..:wink:
But now if insted of the ID I have a date field where the date is save in (Ymd) format ...
Like this ... 20030827 ... how can I delete multiple rows from the table after the year desired from the field data ...
Sopsed that I have like this :
Date | Stuff
-------------
20030810 | First
20031211 | Second
20040103 | Third
.
.
.
So from this table I want to delete the rows that have been retteen in the 2003 year and ofcourse starts with 2003 ...
How can I do that ...???? THANX !!!

Reply With Quote
  #6  
Old August 27th, 2003, 07:34 AM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,840 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Days 36 m 16 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
What type is the field? Date, (var)char, int?

Reply With Quote
  #7  
Old August 28th, 2003, 04:52 AM
clio clio is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Romania
Posts: 45 clio User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 26 m 8 sec
Reputation Power: 6
Send a message via Yahoo to clio
The fild is varchar(50) , and I put the date there with php ... date(Ymd); ..
HOw can I delete the rows(al of them) that bigins with 2003 ... ???
That is my question...

Reply With Quote
  #8  
Old August 28th, 2003, 07:25 AM
bar5cent bar5cent is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 20 bar5cent User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 20 m 39 sec
Reputation Power: 0
have you tried something like...

DELETE FROM db WHERE
(varchar(50) LIKE "2003%");
^
||
||
or date

Reply With Quote
  #9  
Old August 28th, 2003, 08:09 AM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,840 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Days 36 m 16 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
bar5cent's suggestion should work (delete from db where date_column like '2003%') or you can use your database's substring function also.
delete from db where substring(date_column,1,4) = '2003'

On another note, I would suggest that you put dates in date fields instead of varchar or integer, etc...

Reply With Quote
  #10  
Old August 28th, 2003, 09:07 AM
clio clio is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Romania
Posts: 45 clio User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 26 m 8 sec
Reputation Power: 6
Send a message via Yahoo to clio
Talking Mersi ... super

Thanx !!!! bar5cent

THAT REALY HELPED ...

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherBeginner Programming > How to delete multiple rows


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT