lingo5 Posted March 1, 2012 Share Posted March 1, 2012 hi, how can I add more than one ID to a WHERE clause? "SELECT * FROM t_mytable WHERE id_product = 1 "; I need to select products with different id's i.e "SELECT * FROM t_mytable WHERE id_product = 1,2,3,4,5 "; Thanks Link to comment https://forums.phpfreaks.com/topic/258075-please-help-with-where-clause/ Share on other sites More sharing options...
Pikachu2000 Posted March 1, 2012 Share Posted March 1, 2012 Use MySQL's IN() function, or string together a bunch of ORs. Link to comment https://forums.phpfreaks.com/topic/258075-please-help-with-where-clause/#findComment-1322882 Share on other sites More sharing options...
ReeceSayer Posted March 1, 2012 Share Posted March 1, 2012 Like Pikachu2000 said: SELECT * FROM t_mytable WHERE id_product IN (1,2,3); Link to comment https://forums.phpfreaks.com/topic/258075-please-help-with-where-clause/#findComment-1322884 Share on other sites More sharing options...
lingo5 Posted March 1, 2012 Author Share Posted March 1, 2012 Thanks Pikachu, this is how I did it "SELECT * FROM t_mytable WHERE id_product IN ('1','3','4','5')"; Link to comment https://forums.phpfreaks.com/topic/258075-please-help-with-where-clause/#findComment-1322892 Share on other sites More sharing options...
lingo5 Posted March 1, 2012 Author Share Posted March 1, 2012 oooops.... thanks ReeceSayer also. Link to comment https://forums.phpfreaks.com/topic/258075-please-help-with-where-clause/#findComment-1322893 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.