'Get records from mySQL table that have certain ID set, and it's the only record in table
I have a database table that looks like that:
I want to pull all product_id from such table that have certain category_id set, AND this record is the only one for that product ID. (if there are two records for product_id with any category_id, it shouldn't be included).
I tried something like that:
SELECT product_id
FROM `products_categories`
WHERE category_id = 541
AND HAVING COUNT(product_id) = 1;
But that returns a syntax error that I can't figure out. Anyone can advice what I may be doing wrong?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

