473,395 Members | 1,495 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,395 software developers and data experts.

Search Across Two Concatenated Fields

This should be simple but it has me stumped.

I have two fields First_Name and Last_Name. I want to search for John
Smith by entering "John", "Smith" or "John Smith". I have tried to
concatenate the fields with this code and it works with "John" and
"Smith" but comes up blank when I enter "John Smith".

SELECT First_Name, Last_Name FROM ASPP_Users WHERE (First_Name + ' ' +
Last_Name) Like'%" + Replace(Recordset1__r_name, "'", "''") + "%'

Is there something incorrect in the concatenation part of the code ? I
am using MS Access.

Aug 10 '06 #1
1 1227
It's OK now. After many hours I got it to work.

For anyone else who might need it, drop the space inside ' ' and use ''
instead.

So the correct code is :

SELECT First_Name, Last_Name FROM ASPP_Users WHERE (First_Name + '' +
Last_Name) Like'%" + Replace(Recordset1__r_name, "'", "''") + "%'

e_********@hotmail.com wrote:
This should be simple but it has me stumped.

I have two fields First_Name and Last_Name. I want to search for John
Smith by entering "John", "Smith" or "John Smith". I have tried to
concatenate the fields with this code and it works with "John" and
"Smith" but comes up blank when I enter "John Smith".

SELECT First_Name, Last_Name FROM ASPP_Users WHERE (First_Name + ' ' +
Last_Name) Like'%" + Replace(Recordset1__r_name, "'", "''") + "%'

Is there something incorrect in the concatenation part of the code ? I
am using MS Access.
Aug 10 '06 #2

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

Similar topics

4
by: Axel | last post by:
Is it possible to write a Stored Procedure that takes a string of search keywords as argument and returns the recordset? At the mo I am passing the WHERE String as argument. I got this...
6
by: michaelnewport | last post by:
Greetings, I used to do this kind of query in Ingres, where I concatenate (+)various fields as one field and search accordingly. Is there an equivalent method in SQL server ? SELECT...
2
by: B Love | last post by:
Hello Group, I have 2 text fields that I would like to concatenate for use in a table. One field is an ordinary text box. The other is a simple combo box which I use to select one of about ten...
1
by: Jeff Silverman | last post by:
I have a PHP program that almost works. I'm running it from the command line and simulating a form using a GET method. That part is working, but I get spurious records with all of the fields...
3
markmcgookin
by: markmcgookin | last post by:
Hi Folks, I have a VB app, and I have been working at it for a while, and I am now at the stage where I want to create a search function. Now don't be scared! It is in the .Net compact framework,...
14
by: Simon Gare | last post by:
Hi, have a search.asp page with results.asp page drawing data from an SQL db, problem is the user has to type the whole field value into the search box to retrieve the value on results.asp, what...
2
by: macnimation | last post by:
Hi, I have created a Search Input that when a word is typed, I get a result of records based on all or part of the word, which is fine, and this is based across several Fields. Any Table fields...
8
by: Sham | last post by:
I am trying to perform the following query on a table that has been indexed using Full Text Search. The table contains multiple columns than have been indexed. (Below, all xml columns are...
8
by: banderson | last post by:
Hello, I have a combo box in which I want to display multiple fields by concatenating the fields together. If one of those concatenated fields is Null, then the combo box does not show anything. To...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.