Jump to content

Query Help!!!


chevys

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

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.