question

abhinethra avatar image
abhinethra asked

Is it possible to pass as array as the input to a SQL query and perform the following?

I have an array of words keywords = ["what","is","your","favorite","color"] I have a column in a mySQL table as follows **keywords** row1=> what:name row2=> what:favorite:color row3=> what:color:like row4=> what:color:hate i need to pass my array in a sql query and get the row with the highest number of similar words in the row and the array. in the above example i should get row3 as the answer. Is it possible? if so, please help me with the code. I am coding in Java
mysqldelimited-string
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
@SQLShark avatar image
@SQLShark answered
You could load the array of words in to a table (one row per word) and then just join to your master word list and do a COUNT(*) of the results. Then return that to the application.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.