Welcome Guest, Not a member yet? Register   Sign In
Join with a where condition on the joined table
#1

[eluser]bobbob[/eluser]
I am trying to get the event_email_list.email_hash into the result set but depending on the conditions below.
Code:
$q = $this->db->select('events.*, email_lists.list_name,event_email_list.email_hash as TitleLink');
$q = $this->db->where('event_end >',$date_limit);
$q = $this->db->where('event_organiser_id', $user_id);
$q = $this->db->order_by('emails_sent');
$q = $this->db->join('email_lists','email_lists.id = events.list_id','left');
//$q = $this->db->join('event_email_list','event_email_list.event_id = events.id','left');
//$q = $this->db->join("event_email_list","event_email_list.email = .$this->session->userdata('email').");

$q = $this->db->get('events');
How can I get the last 2 commented lines to work as I can't put the session variable like that as it is looking for a table name.column?
What I really mean there is
Code:
join where event_email_list.event_id = event_id AND event_email_list.email = $this->session->userdata('email')
which is really a join and a where clause.
I can't put the where as a simple where as it will limit the results. the email and the event_id are not unique in the table but there will only be one email_hash that matches both conditions.

Tx

Oop Wrong Forum. Is there a way for me to move it?




Theme © iAndrew 2016 - Forum software by © MyBB