Search
 
SCRIPT & CODE EXAMPLE
 

SQL

order child below the parent in mysqli

# If no-parent = 0 instead of null 
SELECT CONCAT(IF(parent = 0,'',CONCAT('/',parent)),'/',id) AS gen_order
FROM table 
ORDER BY gen_order

#and if no-parent = null
ORDER BY COALESCE(parent, id), parent IS NOT NULL, id
Comment

PREVIOUS NEXT
Code Example
Sql :: load utilities in sql server 
Sql :: how to set up an anonymous function to variable in swift 
Sql :: delete and start from 1 primary key muysql 
Sql :: hierarchal database table 
Sql :: SQL Query Records Using Dates 
Sql :: sql shell psql cannot enter password 
Sql :: hive hbase create external table 
Sql :: trigger stock phpmyadmin 
Sql :: configurer mysqlwampserver a distance 
Sql :: how to save result of sqlite query in a table 
Sql :: what does the -p flag do in mysql cli 
Sql :: exel bulk insert 
Sql :: delete recurring email keep smallest id number 
Sql :: copy data from cell to cell mysql 
Sql :: alter fedora mysql 8.0 user 
Sql :: QUERY JPQL 
Sql :: multiple row join 
Sql :: oracle run_duration to number 
Sql :: sql delete row from table where id 
Sql :: SQL Injection Using Multiple Statement 
Sql :: SQL INNER JOIN With AS Alias 
Sql :: sql server split string and insert into table select 
Sql :: how to run sql script in postgresql in windows 
Sql :: count record in same name condition 
Sql :: how to add session data into mysql database from button 
Sql :: creating directory /var/lib/postgresql/data ... initdb: error: could not create directory "/var/lib/postgres/data": Permission denied 
Sql :: intellij idea add mysql connector 
Sql :: oracle convert run_duration to number 
Sql :: sql query contains multiple ids 
Sql :: oracle rolling back 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =