Search
 
SCRIPT & CODE EXAMPLE
 

SQL

how to get parent and child record in single query using sql

SELECT child.Id,
       child.Name,
       child.ParentId,
       parent.Name as ParentName
FROM your_table child
JOIN your_table parent ON child.ParentId = parent.id;
Comment

PREVIOUS NEXT
Code Example
Sql :: sql tabelle erstellen 
Sql :: oracle inner join 
Sql :: convert rows into columns in oracle 
Sql :: linux bash run sql command 
Sql :: SQL Modify Column in a Table -SQL Server 
Sql :: express mysql 
Sql :: influxdb delete measurement based on date 
Sql :: 0 
Sql :: sql get month and year from date 
Sql :: sql view index 
Sql :: declare temp table in sql 
Sql :: sql pivot 
Sql :: sql vs nosql or mysql vs mongodb 
Sql :: sqlite unix timestamp 
Sql :: delete vs truncate sql server 
Sql :: sql insert data 
Sql :: google cloud sql postgres url example 
Sql :: Mysql table variables 
Sql :: how to use query in nosql 
Sql :: match in sql server 
Sql :: timestamp sql 
Sql :: SQL IS NULL With COUNT() 
Sql :: having clause 
Sql :: How do I UPDATE from a SELECT in SQL Server? 
Sql :: generate series sybase 
Sql :: sqlite create record 
Sql :: stored procedure data to table 
Sql :: sql server size of every table in a db 
Sql :: mysql copy table rows from one database to another 
Sql :: homebrew mysql service not starting 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =