Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Comparing Mysql fields

Status
Not open for further replies.

richclever

IS-IT--Management
Oct 5, 2000
127
FR
Hi, I have a table with a field called keywords. In this field, there is a comma delimited list of keywords. I need to compare this field for a particular record with all the other records to find any records that have the same or similar entries in their lists.

e.g. Record1 has the following words in the keyword field
- potato, potatoes, varieties, gardening,
garden, new potatoes
Record2 has the following words in the keyword field
- Robert Burns, Burn's Night, haggis, Rabbie
Burns, scots, scotland, garden

Obviously both fields have the word 'garden', I need to know how to recognise this and flag the second one so it can be identified as being related.

Sorry about the convoluted explanation of my problem but I couldn't think of any other way to put it.

Thanks in advance,

Richard
 
Take each 'keyword' field, turn it into an array
Code:
$arr1 = explode(',',$record1['keyword']);
$arr2 = explode(',',$record2['keyword']);
and use one of the array functions (see < to do the comparision. Based on the results, set your flag accordingly.

Ken
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top