PHWinfo banniere

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

Réponse
 
LinkBack Outils de la discussion
Vieux 24/10/2007, 20h47   #1
Gerard
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Concat alternative

Currently I am running a concat statement to combine a field with a user
name and domain to create and email address. In testing it looks like
running the concat is a very slow command to run. The select statement
currently looks like this.

select concat(user,'@',domain),servername,port from database where
concat(user,'@',domain)='username@domain.com';

  Réponse avec citation
Vieux 24/10/2007, 20h56   #2
Rob Wultsch
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Concat alternative

On 10/24/07, Gerard <gerard.cluster@gmail.com> wrote:
> Currently I am running a concat statement to combine a field with a user
> name and domain to create and email address. In testing it looks like
> running the concat is a very slow command to run. The select statement
> currently looks like this.
>
> select concat(user,'@',domain),servername,port from database where
> concat(user,'@',domain)='username@domain.com';
>

That query will be very slow because mysql will have to examine each
row. You would be far better served to do something like
select concat(user,'@',domain),servername,port
from database
where
user = substring('username@domain.com',0,LOCATE('@','user name@domain.com'))
AND
domain = substring('username@domain.com',LOCATE('@','userna me@domain.com'))

or something like that, or even better split it outside mysql if possible.
--
Rob Wultsch
(480)223-2566
wultsch@gmail.com (email/google im)
wultsch (aim)
wultsch@hotmail.com (msn)
  Réponse avec citation
Vieux 24/10/2007, 23h14   #3
mysql@subtropolix.org
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Concat alternative

Gerard wrote:
> Currently I am running a concat statement to combine a field with a user
> name and domain to create and email address. In testing it looks like
> running the concat is a very slow command to run. The select statement
> currently looks like this.
>
> select concat(user,'@',domain),servername,port from database where
> concat(user,'@',domain)='username@domain.com';
>


Why do CONCAT() twice? Couldn't you just do:

WHERE user = 'username' AND domain = 'domain.com'

Or am i missing something?

brian
  Réponse avec citation
Vieux 26/10/2007, 19h29   #4
Gerard
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Concat alternative

On 10/24/07, mysql@subtropolix.org <mysql@subtropolix.org> wrote:
>
> Gerard wrote:
> > Currently I am running a concat statement to combine a field with a user
> > name and domain to create and email address. In testing it looks like
> > running the concat is a very slow command to run. The select statement
> > currently looks like this.
> >
> > select concat(user,'@',domain),servername,port from database where
> > concat(user,'@',domain)='username@domain.com';
> >

>
> Why do CONCAT() twice? Couldn't you just do:
>
> WHERE user = 'username' AND domain = 'domain.com'
>
> Or am i missing something?
>
> brian
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:
> http://lists.mysql.com/mysql?unsub=g...ster@gmail.com




This is done because the application is not flexible. I can only put one
condition in which goes for the where and select statement.

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


É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,11739 seconds with 12 queries