# How to delete a set of records

**URL:** <https://www.ruby-forum.com/t/how-to-delete-a-set-of-records/49521>\
**Category:** Rails\
**Created:** [November 22, 2005, 5:37pm UTC](https://www.ruby-forum.com/t/how-to-delete-a-set-of-records/49521 "2005-11-22T17:37:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shaun](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f07891/32.png) [@shaun](https://www.ruby-forum.com/u/shaun)\
**Post date:** [November 22, 2005, 5:37pm UTC](https://www.ruby-forum.com/t/how-to-delete-a-set-of-records/49521/1 "2005-11-22T17:37:08Z")

</div>

I’m trying to delete a set of records from the database using parameters  
other than the primary key. Is there a method similar to find\_by\_sql()  
that can be used to issue a delete statement like this. Thanks in  
advance.

Shaun

---

<div class="post-metadata">

**Author:** ![shaun](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f07891/32.png) [@shaun](https://www.ruby-forum.com/u/shaun)\
**Post date:** [November 22, 2005, 5:50pm UTC](https://www.ruby-forum.com/t/how-to-delete-a-set-of-records/49521/2 "2005-11-22T17:50:38Z")

</div>

On 11/22/05, Shaun [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m trying to delete a set of records from the database using parameters  
> other than the primary key. Is there a method similar to find\_by\_sql()  
> that can be used to issue a delete statement like this. Thanks in  
> advance.
> 
> Shaun

Foo.destroy\_all ‘bar \< 5’

[http://rails.rubyonrails.com/classes/ActiveRecord/Base.html#M000698](http://rails.rubyonrails.com/classes/ActiveRecord/Base.html#M000698)

–  
rick  
[http://techno-weenie.net](http://techno-weenie.net)

---

<div class="post-metadata">

**Author:** ![shaun](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f07891/32.png) [@shaun](https://www.ruby-forum.com/u/shaun)\
**Post date:** [November 22, 2005, 6:01pm UTC](https://www.ruby-forum.com/t/how-to-delete-a-set-of-records/49521/3 "2005-11-22T18:01:30Z")

</div>

technoweenie wrote:

> On 11/22/05, Shaun [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > I’m trying to delete a set of records from the database using parameters  
> > other than the primary key. Is there a method similar to find\_by\_sql()  
> > that can be used to issue a delete statement like this. Thanks in  
> > advance.
> > 
> > Shaun
> 
> Foo.destroy\_all ‘bar \< 5’
> 
> [Peak Obsession](http://rails.rubyonrails.com/classes/ActiveRecord/Base.html#M000698)
> 
> –  
> rick  
> [http://techno-weenie.net](http://techno-weenie.net)

Just what I was looking for. Thanks Rick.
