I am getting an error with the below code, it is not fetching any row:
type User struct {
Id int
Username string
Name string
Age int
}
type Salory struct {
Id int
Username string
Salory string
Reamrk string
}
var detail []*models.Salory
if num, err := orm.NewOrm().Raw("SELECT salory.id, salory.salory, salory.reamrk, salory.username, user.username, user.name FROM salory LEFT JOIN user ON salory.username = user.username ORDER BY id ASC",).QueryRows(&detail);
err == nil {
fmt.Printf("%d Total rows read
", num)
for _, post := range detail {
fmt.Printf("Id: %d, UserName: %d, Name: %s
", post.Id, post.Salory.Username, post.Remark)
}
}
I want to know the concept of Left Join in Beego Using Raw SQL to query