I am developing a padrino web application. I have two tables:
User
table: Hasid
,name
,address
fieldsPost
table: Hasid
,user_id
,content
If I join them,
User.join(:posts, user_id:, :id)
they return two fields with the same name id
:
id name address id user_id content
1 jim *** 3 1 post1
I would like to rename each of these id
s. I want the result to be:
u_id name address p_id user_id content
1 jim *** 3 1 post1
I am using Sequel adapter for postgresql db in padrino project. In mysql query, it will be like this:
select u.id as u_id,
u.name,
u.address,
p.id as p_id,
p.user_id as user_id,
p.content
from users u
join posts p on u.id = p.user_id
what should I do? What I want is not sql query, but code of ruby language. Thanks.