Welcome Guest, Not a member yet? Register   Sign In
Help with query structure, upcoming events and birthdays (two separate tables)
#8

[eluser]JamieBarton[/eluser]
Fixed it up a bit, to
Code:
$query = $this->db->query("(SELECT id as id, start_time as date, title as name, 'event' as type FROM events WHERE family_id = $family_id) UNION (SELECT user_id as id, birth_date as date, first_name as name, 'birthday' as type FROM users WHERE family_id = $family_id) ORDER BY date LIMIT $limit");
        
        return $query->result();

However I don't know where to put the WHERE date is greater than today and less than 1 week from now. Can anyone assist with that?

Also, what if I want to grab the users last_name too? How can I add that into the second query without getting an error of having unequal columns?


Messages In This Thread
Help with query structure, upcoming events and birthdays (two separate tables) - by El Forum - 02-21-2010, 12:20 PM



Theme © iAndrew 2016 - Forum software by © MyBB