Welcome Guest, Not a member yet? Register   Sign In
Two identicle column names on join
#1

[eluser]Chris Williams[/eluser]
I'm using a left join on multiple tables where some id columns have the same name.

How to I rdisplay one over the other. I can't use a dot in php like I can in mysql.

Code:
<?=$row->user.user_id?>

This won't work.
#2

[eluser]ontguy[/eluser]
You could try adding an alias to the columns:
Code:
$this->db->select('user.id as User', 'address.id as Address');
#3

[eluser]Chris Williams[/eluser]
When I do this and look at the SQL output, it only grabs the first alias.
#4

[eluser]ontguy[/eluser]
I made a mistake in the code, it should be:
Code:
$this->db->select('user.id as User, address.id as Address');
#5

[eluser]marcoss[/eluser]
[quote author="Chris Williams" date="1213402766"]When I do this and look at the SQL output, it only grabs the first alias.[/quote]

You should provide a sample of your code, seems like you may have an error in there.
#6

[eluser]Chris Williams[/eluser]
Actually, ontguy nailed it.

I probably should have made sure my columns are all unique, but there you have it. :-)




Theme © iAndrew 2016 - Forum software by © MyBB