Gayner Posted September 26, 2009 Share Posted September 26, 2009 SELECT ip.item_id, ip.points_spent, ip.purchase_date, i.title, i.file_path FROM {items_purchased} ip, {items} i WHERE user_id = $user_info[user_id] AND ip.item_id = i.item_id ORDER BY i.title ASC I want to add something like this, tell me if it's wrong? AND pack_id = "1,2,3,4" Pretty mucht hat doesn't work.. but I Want to call pack_id = numbers 1 through 4, possible? Quote Link to comment https://forums.phpfreaks.com/topic/175645-solved-simple-php-query-including-1-5/ Share on other sites More sharing options...
Mark Baker Posted September 26, 2009 Share Posted September 26, 2009 AND pack_id IN ('1','2','3','4') Quote Link to comment https://forums.phpfreaks.com/topic/175645-solved-simple-php-query-including-1-5/#findComment-925537 Share on other sites More sharing options...
Gayner Posted September 26, 2009 Author Share Posted September 26, 2009 AND pack_id IN ('1','2','3','4') i get Column 'pack_id' in where clause is ambiguous Quote Link to comment https://forums.phpfreaks.com/topic/175645-solved-simple-php-query-including-1-5/#findComment-925539 Share on other sites More sharing options...
bothwell Posted September 26, 2009 Share Posted September 26, 2009 Or alternative to the above: SELECT ip.item_id, ip.points_spent, ip.purchase_date, i.title, i.file_path FROM {items_purchased} ip, {items} i WHERE user_id = $user_info[user_id] AND ip.item_id = i.item_id AND (pack_id BETWEEN 1 AND 4) ORDER BY i.title ASC Edit: pack_id will still be ambiguous with the above. You need to use the dot operator on the pack_id command, like where you've got ip.item_id so that mysql knows which table you mean. Quote Link to comment https://forums.phpfreaks.com/topic/175645-solved-simple-php-query-including-1-5/#findComment-925540 Share on other sites More sharing options...
Gayner Posted September 26, 2009 Author Share Posted September 26, 2009 Or alternative to the above: SELECT ip.item_id, ip.points_spent, ip.purchase_date, i.title, i.file_path FROM {items_purchased} ip, {items} i WHERE user_id = $user_info[user_id] AND ip.item_id = i.item_id AND (pack_id BETWEEN 1 AND 4) ORDER BY i.title ASC sweet, thank u sir i had to change it to ip.pack_id Quote Link to comment https://forums.phpfreaks.com/topic/175645-solved-simple-php-query-including-1-5/#findComment-925541 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.