Re: Concat alternative

2007-10-26 Thread Gerard
On 10/24/07, [EMAIL PROTECTED] [EMAIL PROTECTED] 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)='[EMAIL PROTECTED]';
 

 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/[EMAIL PROTECTED]



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


Concat alternative

2007-10-24 Thread Gerard
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)='[EMAIL PROTECTED]';


Re: Concat alternative

2007-10-24 Thread Rob Wultsch
On 10/24/07, Gerard [EMAIL PROTECTED] 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)='[EMAIL PROTECTED]';

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('[EMAIL PROTECTED]',0,LOCATE('@','[EMAIL PROTECTED]'))
AND
domain = substring('[EMAIL PROTECTED]',LOCATE('@','[EMAIL PROTECTED]'))

or something like that, or even better split it outside mysql if possible.
-- 
Rob Wultsch
(480)223-2566
[EMAIL PROTECTED] (email/google im)
wultsch (aim)
[EMAIL PROTECTED] (msn)

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: Concat alternative

2007-10-24 Thread mysql

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)='[EMAIL PROTECTED]';



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/[EMAIL PROTECTED]