Run Code
|
Code Wall
|
Users
|
Misc
|
Feedback
|
About
|
Login
|
Theme
|
Privacy
self join
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Editor:
CodeMirror
EditArea
Simple
Layout:
Vertical
Horizontal
drop table if exists categories cascade; create table categories(acctg_cath_id int, parent int, description text); insert into categories values (1 ,20, 'One'), (9 ,20, 'Nine'), (20, NULL, 'Twenty'), (88, 30, 'Eighty eight'), (89, 30, 'Eighty nine'), (30, NULL, 'Thirty'); select p.acctg_cath_id as parent_cat_id, p.description as parent_descr, c.acctg_cath_id as child_cat_id, c.description as child_descr from categories p join categories c on p.acctg_cath_id = c.parent where p.parent is null order by p.acctg_cath_id, c.acctg_cath_id ;
absolute service time: 0,42 sec
edit mode
|
history
parent_cat_id
parent_descr
child_cat_id
child_descr
1
20
Twenty
1
One
2
20
Twenty
9
Nine
3
30
Thirty
88
Eighty eight
4
30
Thirty
89
Eighty nine