There are no 'different selection criteria'.
The only selection criteria you have are:
- the sessionid field in the cart table must contain $PHPSESSID
- the productid in the products table must be the same as the productid in the cart table.
In MySQL:
$query = "SELECT * FROM cart, product
WHERE cart.productid = product.id
AND cart.sessionid = \"".$PHPSESSID."\"";
Read your local SQL manual about the JOIN statement.