You are here: Re: Syntax? - Searching combined columns « MsSQL Server « IT news, forums, messages
Re: Syntax? - Searching combined columns

Posted by Ross Presser on 10/01/04 11:25

On 31 Aug 2005 10:05:32 -0700, theintrepidfox@hotmail.com wrote:

> Dear Group
>
> The scaenario is as follows:
> FirstName and LastName are separate columns in the contact table and I
> want to be able to search e.g. for the FirstName and part of the
> LastName at the same time e.g. 'John A' should return 'John Adams'.
> Would be grateful if you can give me some hint as I don't seem to get
> it work.
>
> SELECT FirstName, Lastname FROM i2b_contact WHERE (SELECT Firstname +
> Lastname AS CName) LIKE 'John A%'
>
> Thanks very much for your help and efforts!
>
> Martin

SELECT FirstName, Lastname FROM i2b_contact
WHERE Firstname + ' ' + Lastname LIKE 'John A%'

You may do better, index-wise, to split it up:

SELECT FirstName, Lastname FROM i2b_contact
WHERE Firstname like 'John%' AND Lastname like 'A%'

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация