I would like to know how I can use a subquery in FROM clause using gorm. It would look like the following:
SELECT * FROM ( SELECT foo.* FROM foo WHERE bar
Author didn't use any "JOIN" in his SQL.
I didn't find any ORM way, but db.Raw works.
db.Raw
subQuery := db. Select("foo.*"). Table("foo"). Where("bar = ?", "baz"). SubQuery() db.Raw("SELECT * FROM ? as t1 WHERE t1.id=?", subQuery, 1).Find(&rows)