OVH Cloud OVH Cloud

afficher les x premiers...

1 réponse
Avatar
Marc Collin
salut

je cherche à afficher seulement les x premiers caractère d'un champ
texte d'une bd mysql

merci
--
La boîte à prog http://laboiteaprog.com

1 réponse

Avatar
Bruno Baguette
Le Wed, 30 Jun 2004 23:04:10 -0400, Marc Collin a écrit :

je cherche à afficher seulement les x premiers caractère d'un champ
texte d'une bd mysql



Bonjour,

Sous mysql, il y a la fonction SUBSTRING(str FROM pos FOR len)

Extrait de la doc :

The forms without a len argument return a substring from string str
starting at position pos. The forms with a len argument return a substring
len characters long from string str, starting at position pos. The forms
that use FROM are standard SQL syntax.

mysql> SELECT SUBSTRING('Quadratically',5);
-> 'ratically'
mysql> SELECT SUBSTRING('foobarbar' FROM 4);
-> 'barbar'
mysql> SELECT SUBSTRING('Quadratically',5,6);
-> 'ratica'


Cordialement,

--
----------------------------------------
Bruno Baguette -

Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL