Jump to content

[SOLVED] Simple php query including 1-5?


Gayner

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/175645-solved-simple-php-query-including-1-5/
Share on other sites

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.

 

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.