====== Postgres SQL Cheat Sheet ======
For MS SQL, see [[sql_cheat_sheet|SQL Cheat Sheet]]
===== Basic Query =====
Put column names in double quotes.
SELECT
"ApiResources"."Name" AS ApiResourceName
, "ApiResources"."DisplayName" AS ApiResourceDisplayName
, "ApiScopes"."Name" AS ScopeName
, "ApiScopes"."DisplayName" AS ScopeDisplayName
, "ApiResources".*
FROM
config."ApiResources"
LEFT JOIN
config."ApiScopes"
ON "ApiResources"."Id" = "ApiScopes"."ApiResourceId"
WHERE 1 = 1
AND "ApiScopes"."Name" = 'xero_identity_test'
===== TOP n =====
Use ''LIMIT n'' instead.
SELECT *
FROM identity.users
LIMIT 10