SELECT A.field1 FROM tbl1 AS A,tbl2 AS B WHERE A.field2=B.field2;
Or this the correct way
SELECT field1 FROM tbl1 AS A,tbl2 AS B WHERE A.field2=B.field2;
Assuming this is valid, how would you convert it into golang using gorm?
SELECT A.field1 FROM tbl1 AS A,tbl2 AS B WHERE A.field2=B.field2;
Or this the correct way
SELECT field1 FROM tbl1 AS A,tbl2 AS B WHERE A.field2=B.field2;
Assuming this is valid, how would you convert it into golang using gorm?
3
Answers
Actually it depends. If field1 only exists in tbl1 or tbl2 then both would work. Otherwise first one is correct and removes ambiguity.
BTW, instead of using such old style inner join you should write that as:
With gorm:
EDIT? Since you are saying you don’t know anything other than this SQL, you could use raw SQL as such:
Reference: https://gorm.io/docs/query.html
Models
SQL
Gorm