[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 08-22-2008, 02:07 PM   #1 (permalink)
NamePros Member
 
freeflow's Avatar
 
Join Date: Dec 2006
Posts: 135
12.00 NP$ (Donate)

freeflow is on a distinguished road


MySQL – Delete Command

I am looking for the right command to delete all entries in my
guestbook that have a HTTP in them.

Can you correct this command?

mysql_query("DELETE FROM guestbook WHERE Text='%http%'");


Thanks.
freeflow is offline  
Old 08-22-2008, 02:22 PM   #2 (permalink)
RJ
NamePros Founder

Administrator

 
Join Date: Feb 2003
Location: Bay Area, CA
Posts: 13,173
104,201.68 NP$ (Donate)

RJ Has achieved greatnessRJ Has achieved greatnessRJ Has achieved greatnessRJ Has achieved greatnessRJ Has achieved greatnessRJ Has achieved greatnessRJ Has achieved greatnessRJ Has achieved greatnessRJ Has achieved greatnessRJ Has achieved greatnessRJ Has achieved greatness

Find Marrow Donors! Cystic Fibrosis
mysql_query("DELETE FROM guestbook WHERE Text LIKE '%http%'");
RJ is offline  
Old 08-22-2008, 03:26 PM   #3 (permalink)
NPQ's PA, Slave, and On Call Coder

Technical Services


 
Eric's Avatar
 
Join Date: Mar 2005
Posts: 4,545
0.71 NP$ (Donate)

Eric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond repute

Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse
I'd recommend making a database backup first. You never know, you may end up deleting more than you want to
__________________
Eric is offline  
Old 08-22-2008, 03:50 PM   #4 (permalink)
Domains my Dominion
 
sdsinc's Avatar
 
Join Date: Aug 2005
Location: Web 1.0
Posts: 6,284
1,095.94 NP$ (Donate)

sdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond repute

Third World Education Find Marrow Donors! Find Marrow Donors! Find Marrow Donors! Find Marrow Donors! Animal Rescue Animal Cruelty AIDS/HIV Animal Rescue Wildlife Breast Cancer
At least perform a select before the delete...
__________________
Buy now - MassDeveloper.com $500
sdsinc is offline  
Old 08-22-2008, 03:52 PM   #5 (permalink)
NamePros Member
 
Join Date: Sep 2006
Posts: 87
100.00 NP$ (Donate)

Bruce_KD will become famous soon enoughBruce_KD will become famous soon enough


You can also add limits to your deletion, such as
Code:
Delete From `table` where `row` LIKE '%Something%' limit 1
What happens if an error comes up and Something = Nothing?
Then it clears your database.
Using Limit # stops it from deleting too many. It also speeds up queries when dealing with large databases.


Bruce
Bruce_KD is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 02:19 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85