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.
| Author |
Topic |
|
trinm1987
Starting Member
2 Posts |
Posted - 2009-06-26 : 23:00:42
|
| I have database below:table (idbook, idpublish,title)idbook idpublish title1 1 'van hoc viet nam can dai'2 1 'tu hoc english'3 1 tu hoc lap trinh sql server 20054 2 van hoc nuoc ngoai5 3 development webiste with .net 2005i have productore@txtSearch nvarchar(200)BeginSelect ...from bookwhere...endwhen @txtSearch='van hoc can dai'==>idbook14when @txtSearch='lap trinh sql 2005'==>idbook35Thanks you very much |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-06-26 : 23:13:16
|
| declare @txtSearch nvarchar(200)select @txtSearch ='van hoc can dai'select idbook from book where title like '%'+@txtSearch +'%'or select idbook from book where patindex('%'+@txtSearch +'%',username)>0 |
 |
|
|
trinm1987
Starting Member
2 Posts |
Posted - 2009-06-26 : 23:27:46
|
| are you sure?When you enter @txtSearch ='van hoc can dai'database not this record so it don't searchmy idea, we can search word, ex:'van hoc', 'can dai','van'....but i don't codingyou can help meThanks you! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-06-27 : 01:31:16
|
seeing your output, i think what you need is to pass the strings to be searched in following format @txtSearch ='van hoc,can dai'. then in query parse the string based on , delimited and then do your search. something likeSELECT t.*FROM table tINNER JOIN dbo.ParseValues (@txtSearch,',') fON t.title LIKE '%'+ f.Val + '%'parsevalues can be found in below linkhttp://www.sqlteam.com/forums/topic.asp?TOPIC_ID=128201 |
 |
|
|
|
|
|