| | |
WildCard search in SQL Server 2005?
Please support our MS SQL advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Sep 2006
Posts: 116
Reputation:
Solved Threads: 0
I have a table which have person's name as Prefix, firstname, lastname, address as three
different columns.
I want to get all records when fire a query like
SELECT * from Persons where name= 'abcd'
I want such query which can search in all three columns, it means abcd can be in
Prefix, firstname or lastname column.
Actually I have a page in which there are some text boxes which accepts some inputs and
based on that inputs displays matching records in GridView.
Suppose someone entered 'Ind', so my query should find records in all three columns of name.
And if someone entered record in first text box say name and nothing is entered in address text box, then
the records matching with that name with all addresses should get displayed.
How can I do that?
Thanks in advance,
different columns.
I want to get all records when fire a query like
SELECT * from Persons where name= 'abcd'
I want such query which can search in all three columns, it means abcd can be in
Prefix, firstname or lastname column.
Actually I have a page in which there are some text boxes which accepts some inputs and
based on that inputs displays matching records in GridView.
Suppose someone entered 'Ind', so my query should find records in all three columns of name.
And if someone entered record in first text box say name and nothing is entered in address text box, then
the records matching with that name with all addresses should get displayed.
How can I do that?
Thanks in advance,
•
•
Join Date: Sep 2006
Posts: 116
Reputation:
Solved Threads: 0
I have joined three columns as
MS SQL Syntax (Toggle Plain Text)
SELECT (Prefix+' '+firstname+' '+lastname) FROM Persons
•
•
Join Date: Jul 2005
Posts: 483
Reputation:
Solved Threads: 19
sql Syntax (Toggle Plain Text)
SELECT * FROM persons WHERE (prefix LIKE '%'+@input+'%' OR firstname LIKE '%'+@input+'%' OR lastname LIKE '%'+@input+'%') AND address LIKE '%'+@addressinput+'%'
Last edited by campkev; May 9th, 2008 at 3:45 pm.
![]() |
Other Threads in the MS SQL Forum
- Previous Thread: using joining 'line' tables
- Next Thread: String Search in Mobile Applications
| Thread Tools | Search this Thread |
autogrowth connectingtodatabaseinuse count cursor data database datepart dbsize deadlock delete_trigger highperformancecomputing hpc hpcserver2008 ibm iis loop maximum microsoft ms mssql multithreading news number permission query reporting result server services sets source sql sqlserver sqlserver2005 supercomputing uniqueid update view





