Hi.
I am having trouble with a query using a join. I have two tables as follows:
PRODUCTS
->id
->title
->author
->isbn
->description
->picture
PRODUCTS_CATEGORIES
->product_id
->category_id
I need to find all items that have a picture and belong to one of multiple categories. This is my query, however, I am getter an unexplained error and no result set
$sql = "SELECT * FROM products, products_categories WHERE ((products.picture IS NOT NULL) AND (products_categories.category_id ='405' OR products_categories.category_id='416' OR products_categories.category_id='418' OR products_categories.category_id='420' OR products_categories.category_id='430' OR products_categories.category_id='440' OR products_categories.category_id='510' OR products_categories.category_id='580' OR products_categories.category_id='605' OR products_categories.category_id='730' OR products_categories.category_id='792')) ORDER BY rand() LIMIT 4";
Any help is very much appreciated!
Thanks,
Zac
I am having trouble with a query using a join. I have two tables as follows:
PRODUCTS
->id
->title
->author
->isbn
->description
->picture
PRODUCTS_CATEGORIES
->product_id
->category_id
I need to find all items that have a picture and belong to one of multiple categories. This is my query, however, I am getter an unexplained error and no result set

$sql = "SELECT * FROM products, products_categories WHERE ((products.picture IS NOT NULL) AND (products_categories.category_id ='405' OR products_categories.category_id='416' OR products_categories.category_id='418' OR products_categories.category_id='420' OR products_categories.category_id='430' OR products_categories.category_id='440' OR products_categories.category_id='510' OR products_categories.category_id='580' OR products_categories.category_id='605' OR products_categories.category_id='730' OR products_categories.category_id='792')) ORDER BY rand() LIMIT 4";
Any help is very much appreciated!
Thanks,
Zac