chevys Posted December 2, 2009 Share Posted December 2, 2009 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, Quote Link to comment https://forums.phpfreaks.com/topic/183670-query-help/ Share on other sites More sharing options...
The Little Guy Posted December 2, 2009 Share Posted December 2, 2009 What is iv, i, and it? you should use descriptive names... Quote Link to comment https://forums.phpfreaks.com/topic/183670-query-help/#findComment-969467 Share on other sites More sharing options...
fenway Posted December 4, 2009 Share Posted December 4, 2009 Nothing wrong with short aliases... but please show us the actual query being sent to the server. Quote Link to comment https://forums.phpfreaks.com/topic/183670-query-help/#findComment-971232 Share on other sites More sharing options...
premiso Posted December 4, 2009 Share Posted December 4, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/183670-query-help/#findComment-971561 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.