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 > Re: name and surname in a single field
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Re: name and surname in a single field

Réponse
 
LinkBack Outils de la discussion
Vieux 01/10/2007, 18h25   #1
Ale Stanga
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: name and surname in a single field

Peter H. Coffin <hellsop@ninehells.com> wrote:


> "*" is not a LIKE wildcard. "%" and "_" are LIKE wildcards.
>


my query is:
rs.open "select artista, substring(artista, locate(artista, ' ') as
surname , online from artisti where online = 'S' having surname like
'W%' order by surname asc" , conn

but "Andy Warhold" is in the database in the ARTISTA field.
where's the problem?
thanks, Ale.
  Réponse avec citation
Vieux 01/10/2007, 18h27   #2
Ale Stanga
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: name and surname in a single field

Ale Stanga <alessandro.stanga@gmail.com> wrote:

>
> but "Andy Warhold" is in the database in the ARTISTA field.
> where's the problem?
> thanks, Ale.


and the recordest returned by the query is empty.
  Réponse avec citation
Vieux 02/10/2007, 10h34   #3
Captain Paralytic
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: name and surname in a single field

On 1 Oct, 18:25, alessandro.sta...@gmail.com (Ale Stanga) wrote:
> Peter H. Coffin <hell...@ninehells.com> wrote:
>
> > "*" is not a LIKE wildcard. "%" and "_" are LIKE wildcards.

>
> my query is:
> rs.open "select artista, substring(artista, locate(artista, ' ') as
> surname , online from artisti where online = 'S' having surname like
> 'W%' order by surname asc" , conn
>
> but "Andy Warhold" is in the database in the ARTISTA field.
> where's the problem?
> thanks, Ale.


Wouldn't it be easier to say

SELECT
artista,
substring(artista, locate(artista, ' ') as surname,
online
FROM artisti
WHERE online = 'S' AND artista LIKE '% W%'
ORDER BY surname ASC

  Réponse avec citation
Vieux 02/10/2007, 13h03   #4
Captain Paralytic
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: name and surname in a single field

On 1 Oct, 18:25, alessandro.sta...@gmail.com (Ale Stanga) wrote:
> Peter H. Coffin <hell...@ninehells.com> wrote:
>
> > "*" is not a LIKE wildcard. "%" and "_" are LIKE wildcards.

>
> my query is:
> rs.open "select artista, substring(artista, locate(artista, ' ') as
> surname , online from artisti where online = 'S' having surname like
> 'W%' order by surname asc" , conn
>
> but "Andy Warhold" is in the database in the ARTISTA field.
> where's the problem?
> thanks, Ale.


There are 3 mistakes here:

1) The function "substring(artista, locate(artista, ' ')" has a
closing bracket missing. You should have had a syntax error raised!

2) The function "SUBSTRING(artista, LOCATE(artista, ' '))" has the
paramters for LOCATE round the wrong way. It should be
"SUBSTRING(artista, LOCATE( ' ',artista))"

3) The function "SUBSTRING(artista, LOCATE( ' ',artista))" will
include the space in its result and so the LIKE 'W%' will fail,
because it doesn't taek into account the leading space. Thus teh
function "SUBSTRING(artista, LOCATE( ' ',artista))" should read
"SUBSTRING(artista, LOCATE( ' ',artista)+1)"

But apart from the fact that there were so many mistakes, it was
perfectly correct!

  Réponse avec citation
Vieux 02/10/2007, 21h41   #5
Ale Stanga
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: name and surname in a single field

Captain Paralytic <paul_lautman@yahoo.com> wrote:

> 3) The function "SUBSTRING(artista, LOCATE( ' ',artista))" will
> include the space in its result and so the LIKE 'W%' will fail,
> because it doesn't taek into account the leading space. Thus teh
> function "SUBSTRING(artista, LOCATE( ' ',artista))" should read
> "SUBSTRING(artista, LOCATE( ' ',artista)+1)"
>
> But apart from the fact that there were so many mistakes, it was
> perfectly correct!


fantastic!!
thanks a lot!
now all works fine!
  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 06h26.


Édité par : vBulletin® version 3.7.2
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
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 3,11439 seconds with 13 queries