• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Join query problem

#4
[eluser]danmontgomery[/eluser]
[quote author="andriu" date="1267127986"]With the code above I just get either the client or the elevator.[/quote]

You're mistaken... With the code above you get the data from all 3 tables. With active record when you don't specify a select(), it defaults to "SELECT *". When you join tables and SELECT *, it selects all columns from all tables (The values will be NULL when join conditions aren't met). You might have some collisions in column names, but you are getting all of the data. Alternately, you can just specify which table's data you want.

Code:
$this->db->select("incedencias.*, elevators.some_data, clients.some_data");

You can then programmatically determine which fields are null.

To directly answer your question, you can join a table twice (as many times as you want actually, you can even join a table to itself), but I don't think that's what you want to do here.


Messages In This Thread
Join query problem - by El Forum - 02-25-2010, 07:59 AM
Join query problem - by El Forum - 02-25-2010, 08:38 AM
Join query problem - by El Forum - 02-25-2010, 08:48 AM
Join query problem - by El Forum - 02-25-2010, 08:49 AM
Join query problem - by El Forum - 02-25-2010, 09:04 AM
Join query problem - by El Forum - 02-25-2010, 09:30 AM
Join query problem - by El Forum - 02-25-2010, 10:00 AM
Join query problem - by El Forum - 02-25-2010, 10:05 AM
Join query problem - by El Forum - 03-03-2010, 06:00 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.