all groups > sql server (alternate) > august 2005 >
You're in the

sql server (alternate)

group:

Syntax? - Searching combined columns


Syntax? - Searching combined columns theintrepidfox NO[at]SPAM hotmail.com
8/31/2005 10:05:32 AM
sql server (alternate):

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
Re: Syntax? - Searching combined columns Ross Presser
8/31/2005 1:25:04 PM
[quoted text, click to view]

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
Re: Syntax? - Searching combined columns theintrepidfox NO[at]SPAM hotmail.com
9/6/2005 3:08:09 PM

Thanks Ross! Your help is very appreciated!


[quoted text, click to view]
AddThis Social Bookmark Button