Link below is related to my question:
Eloquent Left Join, getting unexpected result
Here's my table structure just to give an overview.
Options:
Event Meta:
Well, it really is the same problem but I thought it's because of Eloquent. When I tried to use PDO querying the problem on my link. It still does the same.
$query = $db->prepare(
" SELECT * FROM event_meta a
LEFT JOIN options b ON b.id = a.meta_value
WHERE a.meta_key = 'logo'
"); $query->execute();
$object = $query->fetchObject();
echo $object->value, '<br>';
echo $object->meta_value;
So what I did is, I have a table called event_meta
and trying to join the options
table to connect them I use b.id
and for event_meta
is a.meta_value
What I want to happen on my end is to retrieve the options.value
first to check if it's empty. If it is empty, I will get the event_meta.meta_value
's value to output it.
So for example on my query above, I want to get the meta_key
called logo. It should get the output of an image name. But since I'm connected to options
table it should get the options.value
. When outputting the options.value
it should be blank. Since the meta_value
of logo does not equals to any options.id
. But it's retrieving the Top Up
value.