The goal
Select data from database using Name-Of-Product
instead of its id.
The problem
My application allows the user to compare product prices. To make some comparison I need to access myapp.com/Product/Compare?Id=1
. I'm upgrading my application and now I want to access myapp.com/Product/Xbox-360
to make the comparison.
How can I select the sluggified word from the database instead of its id? Do I have to unsluggify the string?
Can someone enlighten me?
What I've already tried
I even do not know how to start. In other words, I didn't try nothing. Oh... Actually, if necessary, I already created a method that can sluggify some string, but I don't think it is necessary to post here.
SQL Spotlight
My query to produce the list of products to compare is simple:
Select product.Name,
marketProduct.Price
From app_products As product
Join app_marketProducts As marketProduct
Where product.Id = 1