|
-
Jun 19th, 2004, 01:35 AM
#1
Thread Starter
Addicted Member
Search database
I design table which has column "keywords" for keep keywords seperated by comma (,). If user pass one keyword, how can I know that the keyword user select is exactly match with any keyword in field. I mean I just want SQL return only rows that user's keyword is exactly match with at least one keyword in "keywords" column.
Ex.
PK1 Data1 Data2 keywords
1 1 1 apple, orange
2 2 2 mange, orange
3 3 3 mange, apple
If user select keyword 'orange', SQL must return only row 1 and 2.
-
Jun 19th, 2004, 07:33 AM
#2
Frenzied Member
It's not good db design to have a field set up with multiple values like that. If you know there'll be a limited number of keywords, you could create separate columns for them in each row - keyword1, keyword2, etc.
A better approach is to have separate rows, one keyword in each. As long as it's not a primary or unique field, you can have unlimited rows with the same keyword. The way you have it set up, I think you'd have to read the keyword field of each record and parse the resulting string for the desired keyword. This would be very inefficient and time consuming. But you could do it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|