SELECT OR statement returning all results
Posted: Tue Nov 19, 2013 5:04 am
Hello, I am having an issue returning results based on an orderID. I have two tables containing products and and orderDetails Table. I need to say "WHERE orderdetails.Code = products.Code OR products1.Code
i have done the following but it is returning all the products from the DB
i think this is causing me the issue
i have tested with one or the other but both products isnt working
any ideas?
thanks
i have done the following but it is returning all the products from the DB
Code: Select all
$colname_rsCustomer1 = "-1";
if (isset($_SESSION['OrderID'])) {
$colname_rsCustomer1 = $_SESSION['OrderID'];
}
mysql_select_db($database_astar, $astar);
$query_rsCustomer1 = sprintf("SELECT * FROM aStar_users, aStar_orders, aStar_orderdetails, aStar_products, aStar_fav WHERE aStar_orders.OrderID = %s AND aStar_orders.CustomerID = aStar_users.userID AND aStar_orderdetails.OrderID = aStar_orders.OrderID AND (aStar_orderdetails.ProductID = aStar_products.Code OR aStar_fav.Code)", GetSQLValueString($colname_rsCustomer1, "text"));
$query_limit_rsCustomer1 = sprintf("%s LIMIT %d, %d", $query_rsCustomer1, $startRow_rsCustomer1, $maxRows_rsCustomer1);
$rsCustomer1 = mysql_query($query_limit_rsCustomer1, $astar) or die(mysql_error());
$row_rsCustomer1 = mysql_fetch_assoc($rsCustomer1);Code: Select all
(aStar_orderdetails.ProductID = aStar_products.Code OR aStar_fav.Code)any ideas?
thanks