Alicia Posted February 23, 2010 Share Posted February 23, 2010 Hi, I would like to ask how can I match all values I obtained from a query in a new query? e.g : Task 1 // first query I use mysql fetch array to obtain all bookID that matches my search. e.g : SELECT * FROM `newBooks` WHERE `keyword` = 'computer' AND `new`='Y' Task 2 // how can I get all the bookID fetched from a while loop above and assign it to another new query where I can obtain another value from different table ? e.g ; SELECT * FROM `bookAuthor` WHERE `bookID` = 'All the bookID I obtained' I can accomplish task 2 with a single query right? Please advise and thanks Link to comment https://forums.phpfreaks.com/topic/193109-comparing-mutiple-values-in-a-single-query/ Share on other sites More sharing options...
mapleleaf Posted February 23, 2010 Share Posted February 23, 2010 Put all the book ids in a comma separated string and then use Find_in_Set on your new query. Link to comment https://forums.phpfreaks.com/topic/193109-comparing-mutiple-values-in-a-single-query/#findComment-1016962 Share on other sites More sharing options...
fenway Posted February 24, 2010 Share Posted February 24, 2010 Put all the book ids in a comma separated string and then use Find_in_Set on your new query. Ugh... evil. Why not use a proper many-to-many table? Link to comment https://forums.phpfreaks.com/topic/193109-comparing-mutiple-values-in-a-single-query/#findComment-1017644 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.