Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
Old 06-24-2008, 06:18 PM DELETE Syntax
Super Talker

Posts: 128
Name: Jose daSilva
Trades: 0
Hi

Can somebody help me here:

I have quite a number of rows between a ceta row and another row in my DB that I want to delet.

I tried:

DELETE FROM table WHERE "col1" >= '40000' AND "col1" =<50000It gives me a syntax error.Thanks Josil
josil is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-24-2008, 06:25 PM Re: DELETE Syntax
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
Try
Code:
DELETE FROM table WHERE col1 >= 40000 AND col1 =<50000


Assuming that col1 is of a numerical type.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 06-24-2008, 07:29 PM Re: DELETE Syntax
Super Talker

Posts: 128
Name: Jose daSilva
Trades: 0
Quote:
Originally Posted by JeremyMiller View Post
Try
Code:
DELETE FROM table WHERE col1 >= 40000 AND col1 =<50000
Assuming that col1 is of a numerical type.

Nop

I have tried with comas without comas with parenteses but does not work
josil is offline
Reply With Quote
View Public Profile
 
Old 06-24-2008, 07:33 PM Re: DELETE Syntax
Super Talker

Posts: 128
Name: Jose daSilva
Trades: 0
I forgot to answer that col1 is in fact numeric type instead of col1 as name the real name of the field is id

in other words just to replace col1 by id
josil is offline
Reply With Quote
View Public Profile
 
Old 06-24-2008, 07:58 PM Re: DELETE Syntax
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
Then, what's the error message you get when you do the query? What's the DB structure? Which SQL engine are you using?
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 06-24-2008, 08:05 PM Re: DELETE Syntax
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
DELETE FROM table WHERE id BETWEEN anumber AND anothernumber;
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-24-2008, 08:14 PM Re: DELETE Syntax
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
Is that for different versions of SQL, Chris?

Did you get my PM about your sig?
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 06-24-2008, 08:58 PM Re: DELETE Syntax
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Without knowing the important stuff, this is only a guess, and likely not to contribute much more than others already have.

DELETE table WHERE ID BETWEEN x AND y

Or, better, select the rows you don't want to delete into another table, drop the first, and rename the second. It'll be faster this way.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 06-24-2008, 09:15 PM Re: DELETE Syntax
Super Talker

Posts: 128
Name: Jose daSilva
Trades: 0
Peolple

It was very simple in my case. just made it the following way:

Because onde of the fiels called mails was no data, just...

delete table where 'id' = ''


and that's it. I manage to get a lot of junk in DB

But now I have a quite number of raws cuted. For example I've row 4235 and follwoing row is 5120.

How can now I renumerate the table from row number 1 to whatever number it ends
josil is offline
Reply With Quote
View Public Profile
 
Old 06-24-2008, 10:30 PM Re: DELETE Syntax
ForrestCroce's Avatar
Half Man, Half Amazing

Posts: 3,023
Name: Forrest Croce
Location: Seattle, WA
Trades: 0
Regenerating those ID values so they're sequential is easy. You could drop the column and add another one. You could move the data into a new table with an auto increment ... which would let you keep them in the same order they are now, if that's important.

Those rows you deleted, were the ID values 'connected' to anything? That could be the hard part. I'm guessing you're ok, but...?
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
ForrestCroce is offline
Reply With Quote
View Public Profile Visit ForrestCroce's homepage!
 
Old 06-25-2008, 04:03 AM Re: DELETE Syntax
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Originally Posted by JeremyMiller View Post
Is that for different versions of SQL, Chris?

Did you get my PM about your sig?
Yep to both,

Standard ANSI SQL for the first and the second is, I've not replied 'cos last week was hectic should have more time this week.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-25-2008, 01:28 PM Re: DELETE Syntax
Super Talker

Posts: 128
Name: Jose daSilva
Trades: 0
Thanks people

Everything is fine now...
josil is offline
Reply With Quote
View Public Profile
 
Old 07-01-2008, 11:33 PM Re: DELETE Syntax
Skilled Talker

Posts: 77
Name: Bill Benson
Location: Florida
Trades: 0
I think this is my first post on this forum so hello.

A general suggestion for getting the correct MySql syntax is to use (in this case) phpmyadmin to delete a few rows at a time. You should get a result that shows the query used.

Just a general idea.

oops, on edit its my 6th post

Last edited by bill benson; 07-01-2008 at 11:34 PM..
bill benson is offline
Reply With Quote
View Public Profile
 
Old 07-22-2008, 10:27 AM Re: DELETE Syntax
Experienced Talker

Posts: 46
Trades: 0
DELETE FROM table WHERE col1 >= '40000' AND col1 =< '50000' LIMIT 10

Don't forget to add a limit at the end of your query. Sometimes you can have nasty surprises if you muff up something in your query .
__________________

Please login or register to view this content. Registration is FREE
-> Home of the crasher squirrel
jeff_oneil is offline
Reply With Quote
View Public Profile Visit jeff_oneil's homepage!
 
Reply     « Reply to DELETE Syntax
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.37366 seconds with 12 queries