This isn't a perfect solution, but you could alter the table to include a
unique id column:
alter table aaa add column id int unsigned not null auto_increment, add key
(My test table was aaa -- real original, I know.) On my table, the new
column had a unique id generated as part of the alter.
Then, you can use a two-step process to knock the row out:
select * from aaa where col1='abc' and col2='def' and col3='ghi' limit 1;
delete from aaa where id=1;
It would be pretty cool if the following would work:
delete from aaa where col1='abc' and col2='def' and col3='ghi' limit 1;
However, the LIMIT phrase isn't valid in a delete.
Hope this helps a bit!
> -----Original Message-----
> From: Jann Linder [mailto:jann@stripped]
> Sent: Thursday, March 11, 1999 9:46 PM
> To: mysql@stripped; cgi-list@stripped
> Subject: Delete first found record in SQL select
> OS & PLATFORM: OH--forgot...using DBI w/perl 5 on Linux
> I have a table with 3 fields.
> I have many records with IDENTICAL Fields.
> I want to pass the following:
> delete from tablename where a='a' and b='b' and c='c'
> and have the MySQL remove the FIRST RECORD ONLY where this
> criteria is met.
> How is this possible?
> HLP ASAP!
> Jann Linder
> Web Developer
> Perl Programmer
> Personal Site: http://www.jann.com/
> CalendarPlus Site: http://www.calendarplus.com/