DEV Community

Discussion on: Generate CRUD Golang code from SQL | Compare db/sql, gorm, sqlx, sqlc

Collapse
 
ironsoul0 profile image
Temirzhan Yussupov

Copy-paste of the answer from the comments section:

Good question! You can write any complex queries and generate code for it with sqlc.
For example:

-- name: GetEntryWithAccount :one
SELECT
  e.*,
  a.owner,
  a.balance
FROM
  entries as e
  JOIN accounts as a
  ON e.account_id = a.id
WHERE e.id = $1
LIMIT 1;
Enter fullscreen mode Exit fullscreen mode