# Select where url param

**URL:** <https://www.ruby-forum.com/t/select-where-url-param/119461>\
**Category:** Rails\
**Created:** [November 7, 2007, 6:11am UTC](https://www.ruby-forum.com/t/select-where-url-param/119461 "2007-11-07T06:11:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wiredwizard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/22d042/32.png) [@wiredwizard](https://www.ruby-forum.com/u/wiredwizard)\
**Post date:** [November 7, 2007, 6:11am UTC](https://www.ruby-forum.com/t/select-where-url-param/119461/1 "2007-11-07T06:11:12Z")

</div>

Im new to Ruby on Rails and I’m sure this is Simple Simon question.

Trying to do a sql select where based on a url param

```
This works fine and displays what I want but I want to change the 1

```

to a url param

```
    def list
@product = product.find_by_sql ["SELECT * FROM products WHERE

```

category\_id = 1"]  
end

Parameters: {“id”=\>“1”}

---

<div class="post-metadata">

**Author:** ![wiredwizard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/22d042/32.png) [@wiredwizard](https://www.ruby-forum.com/u/wiredwizard)\
**Post date:** [November 7, 2007, 3:19pm UTC](https://www.ruby-forum.com/t/select-where-url-param/119461/2 "2007-11-07T15:19:17Z")

</div>

On Nov 7, 2007 10:41 AM, Wired W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> category\_id = 1"]  
> end
> 
> Parameters: {“id”=\>“1”}

@product = Product.find\_by\_sql[“SELECT \* FROM products WHERE  
category\_id = ?”, params[:id]]

–  
gavri

> **[Dentistry in Todays World](https://ga-woo.livejournal.com/)**
>
> ga\_woo - the new blog in LiveJournal. There should be new interesting records soon.
