Forum Moderators: open

Message Too Old, No Replies

where condition problem - where =?

mysql any value where condition

         

dareRock

3:20 pm on Mar 30, 2006 (gmt 0)

10+ Year Member



Hey there,

Having problems selecting data from a mysql table where a column can be any value.

eg.
select * from someTable where category_id = '%'

is this the right syntax to grab all data where category_id can be anything?

Thanks

dareRock

3:33 pm on Mar 30, 2006 (gmt 0)

10+ Year Member



btw, i know..

select * from someTable where category_id = '%'
equals
select * from someTable

the select statement im using is more complex.

thanks

dareRock

3:41 pm on Mar 30, 2006 (gmt 0)

10+ Year Member



I figured this out....

I'm using ROR....
--------------------------
@products_pages, @products = paginate :product, :conditions => [ "category_id LIKE? AND brand LIKE? AND gender LIKE?", category_id, brand, gender ], :per_page => 16
--------------------------
changing the '=' to 'LIKE' in the :conditions solved the problem

Searching for anything (Wildcard) would be something like this:
select * from someTable where category_id LIKE '%'

NOT

select * from someTable where category_id = '%'

hope this helps someone else out at somepoint.

defcube

3:56 pm on Mar 30, 2006 (gmt 0)

10+ Year Member



Glad to see people using Ruby on Rails. I wasn't to impressed with the pagination helpers, but I love the rest of the framework.

dareRock

5:15 pm on Mar 30, 2006 (gmt 0)

10+ Year Member



love ROR...

love the cut-down in code...like 1/3 of equivalent PHP app in some cases!

ya, the pagination thing is an issue - we created our own custom pagination helper that we use in all our ror apps.