Jump to content

Recommended Posts

I am trying to pull a scecific ID from a table so I did:

 

ORDER BY i.itmtype WHERE i.itmtype={$2} ASC");

 

Is this even close?

 

Original here:

 

$inv=$db->query("SELECT iv.*,i.*,it.* FROM inventory iv LEFT JOIN items i ON iv.inv_itemid=i.itmid LEFT JOIN itemtypes it ON i.itmtype=it.itmtypeid WHERE iv.inv_userid={$userid} ORDER BY i.itmtype ASC");

 

Thanks,

Link to comment
https://forums.phpfreaks.com/topic/183670-query-help/
Share on other sites

What is iv, i, and it?

 

you should use descriptive names...

 

FROM inventory iv LEFT JOIN items i ON iv.inv_itemid=i.itmid LEFT JOIN itemtypes it

 

Nothing wrong with short aliases...

 

As for the OP, not sure if this is what you were after:

 

$inv=$db->query("SELECT iv.*,i.*,it.* FROM inventory iv LEFT JOIN items i ON iv.inv_itemid=i.itmid LEFT JOIN itemtypes it ON i.itmtype=it.itmtypeid WHERE iv.inv_userid={$userid} AND i.itmtype={$2} ORDER BY i.itmtype ASC");

 

I think that is what you were after. Just needed an AND statement.

 

EDIT:

You may have to change the variable $2 to be the actual variable, as $2 is an invalid variable name in PHP.

Link to comment
https://forums.phpfreaks.com/topic/183670-query-help/#findComment-971561
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.