백엔드/Supabase
[Supabase] 참조테이블의 컬럼값을 기준으로 정렬하는 방법
순코딩
2025. 9. 28. 19:49
https://supabase.com/docs/reference/javascript/order
JavaScript: Order the results | Supabase Docs
JavaScript: Order the results Order the query result by column. You can call this method multiple times to order by multiple columns. You can order referenced tables, but it only affects the ordering of the parent table if you use !inner in the query. Para
supabase.com
const { data, error } = await supabase
.from('instruments')
.select(`
name,
section:orchestral_sections (
name
)
`)
.order('section(name)', { ascending: true })
const { data, error } = await supabase
.from('quiz')
.select(`
name,
참조테이블명 (컬럼영)
`)
.order('section(name)', { ascending: true })
========== 예시 ==========
const { data, error } = await supabase
.from('quiz')
.select(`
name,
quiz_reactions (view)
`)
.order('quiz_reactions(view)', { ascending: true })
========== 해설 ==========
quiz 테이블의 name 컬럼과 quiz_reactions 테이블의 view 컬럼을 조인해서 가져오세요~
가져올 때 quiz_reactions 테이블의 view 컬럼값 기준으로 오름차순 정렬해서 가져오세요~