I'm using Beego ORM for my database accesses. Currently I'm trying to write a query that joins two tables, user and account, and only returns certain columns of the resulting table.
Something like this:
SELECT Email, FirstName, LastName, Organisation
FROM user INNER JOIN account ON user.accountId = account.Id
WHERE Activated = 0
This is what I have so far:
o.QueryTable("user").Filter("Activated", 0).RelatedSel().All(&u, "Email", "FirstName", "LastName")
Now it returns only the columns I specified in the All() function for the user table. However, for the 'account' table it joins on it returns everything. The documentation says this:
qs.RelatedSel("user") // INNER JOIN user, Only query the fields set by expr
If I do this like so:
o.QueryTable("user").Filter("Activated", 0).RelatedSel("organisation").All(&u, "Email", "FirstName", "LastName")
where 'organisation' is a column in the account table, it actually trys to join on organisation which is not a table. How can I get my intended result?