Welcome Guest, Not a member yet? Register   Sign In
Mysql -> getting results from two tables?
#11

[eluser]Johan André[/eluser]
[quote author="BobbyB" date="1243010202"]Thanks again for your help.
But what if a user does not have any invoices yet?
I am also still getting double entries in the users array if a user has more than 1 invoice.

The closest I got was using the query in my first post.
But using "join" I always produce duplicate entires in my array(if a user has more than 1 invoice).

I will probably have to create a sub-array(as alejandra said) with all the invoices a user has and then check for due ones.
Kinda like this:

array(user1=>first_name=>last_name=>sub_array(invoices_user1=>invoice1=>invoice2))user2=>....

Any hints on how to do this?

Thanks in advance![/quote]

Try adding
Code:
$this->db->group_by('users.id');
in the query. That should give you one row per user, but only users having invoices that are past due...


Messages In This Thread
Mysql -> getting results from two tables? - by El Forum - 05-21-2009, 09:32 AM
Mysql -> getting results from two tables? - by El Forum - 05-21-2009, 09:42 AM
Mysql -> getting results from two tables? - by El Forum - 05-21-2009, 09:46 AM
Mysql -> getting results from two tables? - by El Forum - 05-21-2009, 09:54 AM
Mysql -> getting results from two tables? - by El Forum - 05-21-2009, 01:39 PM
Mysql -> getting results from two tables? - by El Forum - 05-22-2009, 02:35 AM
Mysql -> getting results from two tables? - by El Forum - 05-22-2009, 02:53 AM
Mysql -> getting results from two tables? - by El Forum - 05-22-2009, 04:46 AM
Mysql -> getting results from two tables? - by El Forum - 05-22-2009, 04:55 AM
Mysql -> getting results from two tables? - by El Forum - 05-22-2009, 05:36 AM
Mysql -> getting results from two tables? - by El Forum - 05-22-2009, 06:01 AM
Mysql -> getting results from two tables? - by El Forum - 05-22-2009, 06:16 AM
Mysql -> getting results from two tables? - by El Forum - 05-22-2009, 06:57 AM
Mysql -> getting results from two tables? - by El Forum - 05-22-2009, 08:19 AM
Mysql -> getting results from two tables? - by El Forum - 05-22-2009, 10:55 AM
Mysql -> getting results from two tables? - by El Forum - 05-22-2009, 03:19 PM
Mysql -> getting results from two tables? - by El Forum - 08-20-2009, 06:53 AM



Theme © iAndrew 2016 - Forum software by © MyBB