problem with fetching of data.

I want to know the number of ways in which I can fetch the data on a
particular name from database, because I am getting invalid data, for
the name with space such as "abc xyz".. It uses select *from names where
name="abc-xyz", whch is fetching wrong information, so please help
me.And essentially I want to search on name itself rather than ID.

I think you need to provide more information for us to understand the problem (for me to understand it anyway). Can you post the code you are using to search for name “abc xyz” which is being turned into a query “abc-xyz” as that is very odd. If you could post an extract from the code, an extract from the log showing the query, and the table structure then someone may be able to work out what the problem is.

Colin

Colin Law wrote:

I think you need to provide more information for us to understand the
problem (for me to understand it anyway). Can you post the code you are
using to search for name "abc xyz" which is being turned into a query
"abc-xyz" as that is very odd. If you could post an extract from the
code,
an extract from the log showing the query, and the table structure then
someone may be able to work out what the problem is.

Colin

I am using this code.

Uh, you're telling it to substitute a '-' for white-space in the name; if
that's not what you want, don't do it :slight_smile:

Look at your gsub; if you want a space instead of '-', it should be
pretty obvious what to do :slight_smile:

Open up irb and play with it a bit until you get the result you want:

irb(main):001:0> ("abc
xyz".gsub(/[^[:alnum:]'&''.''!']/,'-')).squeeze("-").chomp("-")
=> "abc-xyz"