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
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.

 

Link to comment
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

 

sweet, thank u sir

 

i had to change it to ip.pack_id

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.