hii all,
i have aproject where...
wen i enter a text in the textbox..., accordingly it should search in teh first name and last name of the database and display the records
How to search records by name....???
plz some one help me the query...
thnx..
hepsi..
4 2246
I think you could try a number of approaches. Two I can think of are:
1. Concatenate the two columns: -
SELECT CONCAT(first_name,' ',last_name) AS name FROM table WHERE CONCAT(first_name,' ',last_name) LIKE 'name_entered_in_text_box';
-
NB - if you want exact matches don't use LIKE, just use =. If you want more results, put some wildcards (%) in your LIKE clause (ie LIKE '%henry%').
2. Search each column for the same term: -
SELECT first_name, last_name FROM table WHERE first_name LIKE '%henry%' OR last_name LIKE '%henry%';
-
This will give lots of results as used % before and after and I used OR. Cut the results by using fewer '%' and using AND instead of OR.
Hope that sheds some light on your problem! Good luck!
Henry
I think you could try a number of approaches. Two I can think of are:
1. Concatenate the two columns: -
SELECT CONCAT(first_name,' ',last_name) AS name FROM table WHERE CONCAT(first_name,' ',last_name) LIKE 'name_entered_in_text_box';
-
NB - if you want exact matches don't use LIKE, just use =. If you want more results, put some wildcards (%) in your LIKE clause (ie LIKE '%henry%').
2. Search each column for the same term: -
SELECT first_name, last_name FROM table WHERE first_name LIKE '%henry%' OR last_name LIKE '%henry%';
-
This will give lots of results as used % before and after and I used OR. Cut the results by using fewer '%' and using AND instead of OR.
Hope that sheds some light on your problem! Good luck!
Henry
thnx for ur reply...
Hi,
If my problem is user input one keyword then i wan to find all the columns in the tables or all the tables in the database?
Eg. table_employee, table_customer, table_product. Each tables got a lot of columns then i wan to find out the similar with the keyword record.
Can someone guide me?
Thanks
Hi,
If my problem is user input one keyword then i wan to find all the columns in the tables or all the tables in the database?
Eg. table_employee, table_customer, table_product. Each tables got a lot of columns then i wan to find out the similar with the keyword record.
Can someone guide me?
Thanks
Google about how to use LIKE with wildcards.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Nash Kabbara |
last post by:
Hi all,
I just finished writing a log reader that reads xml logs (about 1 to 2 MB
large). At the command line you can specify the file name, the name of the
element and it's value like so: logreader log.txt MyElement myvalue
In retrospect, I've noticed that it takes a long time to process. The time
is spent on comparing the value of all...
|
by: Ludwig77 |
last post by:
I read that there are some tags that can be entered in a web page's
meta tags in order to prevent web bot searching and indexing of the
web page for search engines.
What is the tagging that I would need to use?
|
by: Jason |
last post by:
I would like to be able to place a command button on a primary
(parent) form that opens up a subform. I want to use this subform to
search for or limit the recordset of data in the primary form. The
database is setup as follows: the primary form is named
"TestDataCleanup" which is based on a table named "Test_Results". This
primary form...
|
by: Jason |
last post by:
I would like to be able to place a command button on a primary
(parent) form that opens up a subform. I want to use this subform to
search for or limit the recordset of data in the primary form. The
database is setup as follows: the primary form is named
"TestDataCleanup" which is based on a table named "Test_Results". This
primary form...
|
by: Geoff Jones |
last post by:
Hiya
I have a DataTable containing thousands of records. Each record has a
primary key field called "ID" and another field called "PRODUCT" I want to
retrieve the rows that satisy the following criteria:
I have a list of about 100 numbers which correspond to the ID field and also
another 40 say numbers corresponding to the numbers in the...
| |
by: martin DH |
last post by:
I have an Access database of employees.
Each employee has a unique identification number called "BANNER_ID".
Each employee's last name and first name are in the database but are not unique (obviously).
The data is stored in a table named EMPLOYEE.
I want to create a search option whereby managers can search for an employee by "BANNER_ID"
by...
|
by: BOMEz |
last post by:
Hi all,
I'm trying to write up my first SQL database which I would want to be search able. Now currently I can have it search by First Name and Last Name. My code for the search goes like :
$search = "SELECT *
FROM `Customer_info`
WHERE `First Name` LIKE CONVERT( _utf8 '$_POST'
USING latin1 )
COLLATE latin1_swedish_ci
AND `Last Name`...
|
by: lemlimlee |
last post by:
hello,
this is the task i need to do:
For this task, you are to develop a Java program that allows a user to search or sort an array of numbers using an algorithm that the user chooses. The search algorithms that can be used are Linear Search and Binary Search. The sorting algorithms are bubble, selection and Insertion sort.
First, the user...
|
by: icsnetuk |
last post by:
Hi,
I have a table called applicants
There is a form also called applicants which I use to view / edit the data.
On my main dashboard form which is where all of the main options are for the database (also the startup form) I have 4 search boxes which are called:
First Name
Last Name
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |