Welcome Guest, Not a member yet? Register   Sign In
SQL : join with tables with same fields name (eg primary id) return invalid results
#1

Hi,

I noticed that if I build a query with 2 tables having the same name for primary key (and I guess this will be the case with any other field), the result is invalid as the id key in the resulting array contains only the id of the joined table.

This is for example the case in the documentation :


PHP Code:
$builder->db->table('blog');
$builder->select('*');
$builder->join('comments''comments.id = blogs.id');
$query $builder->get();

// Produces:
// SELECT * FROM blogs JOIN comments ON comments.id = blogs.id 



We should have 2 id keys (I know this isn't possible in php, but the name of the result array key should be blogs.id and comments.id)


Sincerly,

Fred
Reply


Messages In This Thread
SQL : join with tables with same fields name (eg primary id) return invalid results - by Fred9176 - 11-27-2020, 06:20 AM



Theme © iAndrew 2016 - Forum software by © MyBB