There is such a database structure.
Tables:
cats_arts
- article categoriessites
- sites where articles should be placedarticles
- the articles themselves
Fields of the cats_arts
table: id
, name
Fields table sites
: url
, id
Fields of the articles
table: id
, site_id
, category(id категории)
...
I need a request to get all the categories used on the site, I got such a request:
$site = "http://test.com/"; $res = mysql_query("SELECT c.id,c.name FROM cats_arts c LEFT JOIN sites a ON a.url='$site' LEFT JOIN articles b ON b.site_id=a.id WHERE c.id=b.category");
But for some reason, such a request displays several times the same category (Help please ...
PS Is the SQL query correct, or is it still MySQL?