3 ms·
I just tried this in MariaDB 10.5.10 on my personal blog database and it doesn't work. `post` <- many to many -> `tag` With LEFT JOIN: SELECT posts.title,
by bruce343434 5y ago
I just tried this in MariaDB 10.5.10 on my personal blog database and it doesn't work. `post` <- many to many -> `tag`
With LEFT JOIN:
SELECT posts.title,
GROUP_CONCAT(tags.tag) AS tagarr
FROM posts
LEFT JOIN post_tags ON post_tags.post_id = posts.id
LEFT JOIN tags ON tags.tag_id = post_tags.tag_id
With WHERE:
SELECT posts.title,
GROUP_CONCAT(tags.tag) AS tagarr
FROM posts, post_tags, tags
WHERE posts.id *= post_tags.post_id
AND tags.tag_id *= post_tags.tag_id
It gives:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '= post_tags.post_id [...]
- da_chicken 5y agoThe trouble you're having there is that there is no standard syntax for ANSI 89 outer joins at all. All outer joins were RDBMS-specific syntax. Indeed, if I remember right, left outer comma joins are *= for Oracle and =* for DB2 (or was it =+). MySQL has never supported any other syntax for outer joins, but it does support ANSI 89 (comma) inner joins. The ANSI 89 syntax for inner joins is pretty ubiquitous, as it can be a little easier to write code generators that way.