Reputation: 87
I have the following Query:
At the moment i get the following code:
It gives back only one tag not the three tags in the database.
The database looks like this:
In this Database are 3 tags with bm_tagslang = 'de' but i only get one.
Does someone know what i am doing wrong?
Upvotes: 0
Views: 43
Reputation: 1269633
Move tagslang.lang
into the on
condition. When there is no match, it is NULL
, so it changes the left join
to an inner join
:
on blog.id = tagslang.blogid and tagslang.lang = ?
You also need to change the group by
. It should be:
group by blog.id
Otherwise, you may be grouping by a NULL
value.
As a note: Do not use columns in the group by
that are not in the SELECT
. This is a MySQL (mis)feature that should not be used unless you really understand what you are doing.
Upvotes: 1