mySQL OR returning all results..
I have a select statement that is checking if a product matches an orderID. I have two tables for products and and orderDetail, at the moment all the records are being return rather that jkust the ones based on the orderID, i think is must be an issue with the OR in the statment, as seperatly (without the or) the correct results are being returned.
I need to say "WHERE orderdetails.Code = products.Code OR products1.Code
$colname_rsOrder = "-1";
if (isset($_SESSION['OrderID'])) {
$colname_rsCustomer = $_SESSION['OrderID'];
}
mysql_select_db($database_momo, $momo);
$query_rsOrder = sprintf("SELECT * FROM momo_users, momo_orders, momo_orderdetails, momo_products, momo_fav WHERE momo_orders.OrderID = %s AND momo_orders.CustomerID = momo_users.userID AND momo_orderdetails.OrderID = momo_orders.OrderID AND (momo_orderdetails.ProductID = momo_products.Code OR momo_fav.Code)", GetSQLValueString($colname_rsOrder, "text"));
$query_limit_rsOrder = sprintf("%s LIMIT %d, %d", $query_rsOrder, $startRow_rsOrder, $maxRows_rsOrder);
$rsOrder = mysql_query($query_limit_rsOrder, $momo) or die(mysql_error());
$row_rsOrder = mysql_fetch_assoc($rsOrder);
