Hello,
Example:
I have 100 rows that all have the field vaule of 'XYZ' I would like to
delete only 10 of those rows.
Is there such a query like "Delete 10 rows from table where table.field
= 'XYZ'"
Thanks,
Patrick 7 5656
>I have 100 rows that all have the field vaule of 'XYZ' I would like to delete only 10 of those rows.
Is there such a query like "Delete 10 rows from table where table.field = 'XYZ'"
Have you tried:
delete from table where table.field = 'XYZ' limit 10;
?
This is one of the reasons why a field:
id int not null auto_increment primary key
is useful. It guarantees you will be able to generate a query to just
delete what you want to delete.
Gordon L. Burditt
Hey thanks... that worked.
My table does have auto_inc, int primary key... How can I do my quiery
if the rows are not in consecutive order?
delete from table where table.id = '1' and table.id ='2' and table.id =
'10' etc....
Patrick pa**************@gmail.com wrote: Hey thanks... that worked.
My table does have auto_inc, int primary key... How can I do my quiery if the rows are not in consecutive order?
delete from table where table.id = '1' and table.id ='2' and table.id = '10' etc....
delete from table where id in (select id from table where field='XYZ'
limit 10)
First time posting and may not be right, but that'd be where I'd start from.
Cheers,
Andy
> delete from table where id in (select id from table where field='XYZ' limit 10)
In theory that's right, but I think there's still a limitation in MySQL that
doesn't allow to use sub-selects in delete statements that refer to the same
table as the outer query. So I fear that this query will not work, yet.
Markus
>My table does have auto_inc, int primary key... How can I do my quiery if the rows are not in consecutive order?
delete from table where table.id = '1' and table.id ='2' and table.id = '10' etc....
There's also:
delete from table where table.id in (1, 2, 10, 86, 37, 666);
Gordon L. Burditt
Markus Popp wrote: delete from table where id in (select id from table where field='XYZ' limit 10)
In theory that's right, but I think there's still a limitation in MySQL that doesn't allow to use sub-selects in delete statements that refer to the same table as the outer query. So I fear that this query will not work, yet.
OK, well nice to know it should work in theory (do you know if it would
work in MySQL 5.0?).
More out of interest than anything else....
Cheers,
Andy
> OK, well nice to know it should work in theory (do you know if it would work in MySQL 5.0?).
Unfortunately not.
It might be possible to do it with a join - but it might be easier to choose
the
delete from table where id in (1, 4, 6, 8);
way.
Markus This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Gary |
last post by:
I haver a table of students - Say 100 students that I need to be able to
update/delete and amend. I know I can do this one student at a time which is
simple but lets say I want to see all the...
|
by: Epetruk |
last post by:
Hi,
I have a mySql question here on updates to multiple tables.
Here's a simple schema to clarify things:
Structure
Table A
|
by: shank |
last post by:
I'm trying to use online samples for submitting multiple records from ASP
into a stored procedure. Failing! Through the below form, a user could be
submitting many records at a time. I'm not...
|
by: Zak McGregor |
last post by:
Hi all
I have a table, for simplicity's sake containing one field, called unid.
for example, select unid, oid from table gives me something like this:
unid | oid
---------+---------
|
by: JonH |
last post by:
Ok, I have this dynamically created table in my one of my php forms
that shows the names of the people the user has entered into a text
field. When they hit add a row displays, showing the name...
| |
by: Jim Michaels |
last post by:
Is it safe to do what is below? deleting from a resultset while you are
processing it? I don't know how dynamic the SQL database is. I assume you
get a cursor to live dataset. Even if it is a...
|
by: MP |
last post by:
Hi
trying to begin to learn database using vb6, ado/adox, mdb format, sql
(not using access...just mdb format via ado)
i need to group the values of multiple fields
- get their possible...
|
by: arizal |
last post by:
Hi ,
I am trying to figure out why my PHP code to delete multiple value by selecting the checkbox is not working. My php code is listed as below
<?php
$sql = "Select * from list;";...
|
by: nigelesquire |
last post by:
Please help!
I'm trying to clone and delete multiple rows with JavaScript.
I need two delete buttons that work...!
I only have one for now, but it's not working properly, the output count is...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |