PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.databases.mysql > Regular Expressions problem
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Regular Expressions problem

Réponse
 
LinkBack Outils de la discussion
Vieux 15/10/2007, 06h27   #1
jatrojoomla
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Regular Expressions problem

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

  Réponse avec citation
Vieux 15/10/2007, 06h44   #2
Gordon Burditt
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Regular Expressions problem

>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.


  Réponse avec citation
Vieux 15/10/2007, 11h05   #3
jatrojoomla
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Regular Expressions problem

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

  Réponse avec citation
Vieux 15/10/2007, 11h20   #4
Captain Paralytic
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Regular Expressions problem

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.

  Réponse avec citation
Vieux 15/10/2007, 13h39   #5
Peter H. Coffin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Regular Expressions problem

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"
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 01h27.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11727 seconds with 13 queries