473,387 Members | 1,453 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Syntax? - Searching combined columns


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

Aug 31 '05 #1
2 1322
On 31 Aug 2005 10:05:32 -0700, th************@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%'
Aug 31 '05 #2

Thanks Ross! Your help is very appreciated!
Ross Presser wrote:
On 31 Aug 2005 10:05:32 -0700, th************@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%'


Sep 6 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: hivie | last post by:
I have a problem that is causing me problems. I have a text file that stores 5 lines of crap (stuff that I dont need( for the user only)). After that there is data that is in three columns...
10
by: sffan | last post by:
I am new to database programming and was curious how others solve the problem of storing encrypted in data in db table columns and then subsequently searching for these records. The particular...
8
by: Jan van Veldhuizen | last post by:
The UPDATE table FROM syntax is not supported by Oracle. I am looking for a syntax that is understood by both Oracle and SqlServer. Example: Table1: id name city ...
8
by: tom | last post by:
I am new to SQL administration. >From a list of IDs that are the primary key in one table (i.e. Customer Table), I want to make changes in tables that use those IDs as a foreign key. ...
7
by: Brian Mitchell | last post by:
Is there an easy way to pull a date/time stamp from a string? The DateTime stamp is located in different parts of each string and the DateTime stamp could be in different formats (mm/dd/yy or...
2
by: rockstar_ | last post by:
Hello all- I'm developing a Content Management software for my own site, and possibly package and deploy to other sites (for friends, family, etc.) The content management software is combined...
8
by: Allan Ebdrup | last post by:
What would be the fastest way to search 18,000 strings of an average size of 10Kb, I can have all the strings in memory, should I simply do a instr on all of the strings? Or is there a faster way?...
3
by: fezza1 | last post by:
Hello, I need some help, so thanks in advance. My database has 5 columns matching to particular years, i.e.,PrevYr, PrevYr1, PrevYr2, PrevYr3, PrevYr4. In a simple query, I've combined all...
2
by: Bart Kastermans | last post by:
I have a file in which I am searching for the letter "i" (actually a bit more general than that, arbitrary regular expressions could occur) as long as it does not occur inside an expression that...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.