Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Simple Search

Author  Topic 

ryandavebrigino@yahoo.com
Starting Member

9 Posts

Posted - 2008-07-21 : 22:50:09
good day everyone.

regards to visakh16
- the syntax from your last reply works. thanks.


to day my problem is search.
recently i am using the keyword LIKE and my syntax is like this.

SELECT ItemName
FROM Tbl_ItemMasterfile
WHERE ItemName like '%dvd%'

and i get a result set of items that contains the word 'dvd'

LG DVD
SAMSUNG DVD
SONY DVD



now my boss wants a SEARCH QUERY that would look something like this
SELECT ItemName
FROM Tbl_ItemMasterfile
WHERE ItemName like '%dvd tv%'

and I need to return the items containing either the word
'dvd' OR 'tv'

this is the result set i need to return

LG DVD
SAMSUNG DVD
SONY DVD
LG TV
SAMSUNG 14" TV
SONY DVD TV

Im a beginner in SQL so i only know basics.
please be gentle.
Thanks...

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-07-21 : 22:55:59
[code]SELECT ItemName
FROM Tbl_ItemMasterfile
WHERE ItemName like '%dvd%'
or ItemName like '%tv%'[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

ryandavebrigino@yahoo.com
Starting Member

9 Posts

Posted - 2008-07-21 : 23:12:17
thanks for the reply khatan

but the parameter that I need to passed to the query should came from only one textbox.
so i cant use 'OR' in the query.


what i need to pass is only the string 'dvd tv'
and return this result.
LG DVD
SAMSUNG DVD
SONY DVD
LG TV
SAMSUNG 14" TV
SONY DVD TV
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-07-21 : 23:38:13
[code]SELECT ItemName
FROM Tbl_ItemMasterfile
INNER JOIN dbo.fnParseList(' ', 'dvd tv')
ON ItemName LIKE '%' + Data + '%'
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -