Jlwalm Posted November 11, 2008 Share Posted November 11, 2008 I would like to create a query that queries a database using an array containing key words. The query will select all the records that match any word in the array. I don't have any idea how to do this and am hoping someone can point me in the right direction. many thanks Jlwalm Link to comment https://forums.phpfreaks.com/topic/132266-mysql-select-query-using-an-array-of-key-words/ Share on other sites More sharing options...
BioBob Posted November 11, 2008 Share Posted November 11, 2008 SELECT * FROM db WHERE field NOT IN ('apple','orange','banana'); I think that will work... Link to comment https://forums.phpfreaks.com/topic/132266-mysql-select-query-using-an-array-of-key-words/#findComment-687615 Share on other sites More sharing options...
JasonLewis Posted November 11, 2008 Share Posted November 11, 2008 mysql_query("SELECT * FORM table WHERE column_name IN (" . implode(',', $array) . ")"); Something like that? Google "MySQL IN". Link to comment https://forums.phpfreaks.com/topic/132266-mysql-select-query-using-an-array-of-key-words/#findComment-687616 Share on other sites More sharing options...
Jlwalm Posted November 11, 2008 Author Share Posted November 11, 2008 sorry, I forgot to mention. The array will need to be either in a text file or in another database table. thanks Link to comment https://forums.phpfreaks.com/topic/132266-mysql-select-query-using-an-array-of-key-words/#findComment-687617 Share on other sites More sharing options...
trq Posted November 11, 2008 Share Posted November 11, 2008 So you need help creating the array aswell then? Link to comment https://forums.phpfreaks.com/topic/132266-mysql-select-query-using-an-array-of-key-words/#findComment-687639 Share on other sites More sharing options...
Jlwalm Posted November 11, 2008 Author Share Posted November 11, 2008 yes, I need help with keeping some key words in a table and using an array to find out which of those key words exist somewhere in another table. thanks Link to comment https://forums.phpfreaks.com/topic/132266-mysql-select-query-using-an-array-of-key-words/#findComment-687774 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.