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 2008 Forums
 Transact-SQL (2008)
 select query

Author  Topic 

manoj.p
Starting Member

1 Post

Posted - 2010-11-24 : 10:39:56
I have a table which has foll. records

Id Kwd
1 maid
2 maids
3 mai
4 maids in carribean
5 Carribean
6 Cariibean's maids


From above there are few scenarios that user will search for

Example 1 :
Kwd ="maids"
Result : should display 1,2,4,6

Id Kwd
1 Fashion Designer
2 Designer Course
3 Designer
4 Father
5 Fast Bowler
6 Desert


From above there are few scenarios that user will search for

Example 2 :
Kwd ="Fashion Designer"
Result : should display 1,2,3


visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-11-24 : 10:46:30
how maids returned 1 & 5? 1 has only maid while 5 doesnt have any matches at all

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2010-11-24 : 11:48:22
I think oppey means 6

In any case, what class is this?

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2010-11-24 : 11:58:37
Hmm.
Anything you are having problems with or did you just want to let us know what your users will do?

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2010-11-24 : 12:30:12
At any rate, you'll want a function to split your input string into a recordset. There are plenty of examples of the code needed to do this. They typically take a string and a delimiter, in your case a blank. Once you have that you can join your Keyword table to the results of the Split function using the LIKE comparison. This should get you what you want.

If, after you have this put together, you are still having troubles, show us the code you wrote and we'll see if we can be of service.

=======================================
No matter what side of the argument you are on, you always find people on your side that you wish were on the other. -Jascha Heifetz, violinist (1901-1987)
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2010-11-25 : 05:48:58
You should create a full text index on this table and do a FREETEXT search instead.

- Lumbago

My blog (yes, I have a blog now! just not that much content yet)
-> www.thefirstsql.com
Go to Top of Page
   

- Advertisement -