|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi!
I am trying to fetch keyword 'banga' from one of my table 'helth_test'. on that table word 'banga' may be one or more on a row / colum / cell I am trying from: http://dev.mysql.com/doc/refman/5.0/en/regexp.html putting syntax: SELECT * FROM `helth_test` WHERE 'banga' REGEXP '^(banga)*$'; BUT SHOWING ALL ROWS. HOW TO GET ONLY THOSE ROWS WHERE 'banga' CONTAINING ONLY ME PLEASE, Thanks Sukalyan |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
>I am trying to fetch keyword 'banga' from one of my table
>'helth_test'. From which column? >on that table word 'banga' may be one or more on a row / colum / cell I don't understand what you are asking for here. If you're asking to find all rows containing 'banga' in *any* column, that's not how databases are generally used. I would not expect to ever find 'banga' in a column labelled `hat_size`, for example. >I am trying from: >http://dev.mysql.com/doc/refman/5.0/en/regexp.html > >putting syntax: >SELECT * >FROM `helth_test` >WHERE 'banga' REGEXP '^(banga)*$'; > >BUT SHOWING ALL ROWS. Using REGEXP where both sides are constant strings is generally unproductive. 'banga' is a five-character string beginning with 'b' and ending in 'a'. `banga` is the column named banga. banga is also the column named banga, unless and until banga becomes a reserved word, in which case it's a syntax error. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
SELECT *
FROM helth_test WHERE data_one LIKE '%banga%' LIMIT 0 , 30 >>>>>>>> it pick: <anything> banga <anything> ------------------------------------------------------------------------------------ If I wants to use Regular Expressions on above query then what will be the syntax Please give me any one example syntax Sorry for my english Thanks |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On 15 Oct, 10:05, jatrojoomla <jatrojoo...@gmail.com> wrote:
> SELECT * > FROM helth_test > WHERE data_one LIKE '%banga%' > LIMIT 0 , 30 > > > > it pick: > <anything> banga <anything> > > ------------------------------------------------------------------------------------ > If I wants to use Regular Expressions on above query then what will > be the syntax > Please give me any one example syntax > Sorry for my english > Thanks This smacks of a schema that violates first normal form (1NF). Normalize your data, you will benefit. |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
On Mon, 15 Oct 2007 04:27:25 -0000, jatrojoomla wrote:
> Hi! > I am trying to fetch keyword 'banga' from one of my table > 'helth_test'. > > on that table word 'banga' may be one or more on a row / colum / cell > > I am trying from: > http://dev.mysql.com/doc/refman/5.0/en/regexp.html > > putting syntax: > SELECT * > FROM `helth_test` > WHERE 'banga' REGEXP '^(banga)*$'; Additionally, the regexp is not correct. Regexps are not file system patterns. * does not mean what you think it means. You have 'banga' tied to the beginning of the tested column value, and it doesn't sound like you want to find it only at the beginning. And there is almost never a need to a pattern like 'stuff.*$'; 'stuff' will do as well. (I'd go so far as to say you'd NEVER need such a pattern, but I'm sure someone would follow-up with an example where such a thing would actually be needed.) You've essentially asked "give me all the rows with zero or more instances of banga in them"; of course you're going to get all rows. That's what you asked for. O'Reilly publishes a very good book on regular expression matching, but http://www.regular-expressions.info/quickstart.html will at least fix these kinds of misimpressions. -- 5. The artifact which is the source of my power will not be kept on the Mountain of Despair beyond the River of Fire guarded by the Dragons of Eternity. It will be in my safe-deposit box. The same applies to the object which is my one weakness. --Peter Anspach "Evil Overlord" |
|
![]() |
| Outils de la discussion | |
|
|