Reputation: 1516
I have got a few tables which I am trying to join.
I just don't know of a way of doing what I need, it is a bit hard to explain so I will show you the query so far:
SELECT exp_channel_data.field_id_102,
exp_channel_data.field_id_104,
exp_channel_data.field_id_126,
exp_channels.deft_status
FROM exp_channel_data
INNER JOIN exp_channels
ON exp_channels.channel_id = exp_channel_data.channel_id
INNER JOIN exp_channel_titles
ON exp_channels.channel_id = exp_channel_titles.channel_id
WHERE exp_channels.channel_id = 18
AND exp_channel_titles.channel_id = 19
The bit that doesn't work is the AND exp_channel_titles.channel_id = 19
The issue is that I get a 0 result set back. Yet I know that both columns have data in them. Although they are totally separate data-sets.
exp_channels
contains all the data such as Day, Time, Price etc
exp_channel_titles
contains all of the title information
But I need to combine the two together so I can get a result set of:
"Title, Day, Teacher, Time" etc
So I was just wondering if anyone had a solution on how to do this?
Thanks!
Upvotes: 1
Views: 3787
Reputation: 160843
Because you are using inner join, so all the channel_id
of one row should be same.
Do you mean OR
?
SELECT exp_channel_data.field_id_102,
exp_channel_data.field_id_104,
exp_channel_data.field_id_126,
exp_channels.deft_status
FROM exp_channel_data
INNER JOIN exp_channels
ON exp_channels.channel_id = exp_channel_data.channel_id
INNER JOIN exp_channel_titles
ON exp_channels.channel_id = exp_channel_titles.channel_id
WHERE exp_channels.channel_id = 18
OR exp_channel_titles.channel_id = 19
OR you could use IN
.
WHERE exp_channels.channel_id IN (18, 19)
Upvotes: 2