Last active
March 18, 2020 14:00
-
-
Save locvfx/1f9106ab5dfe6bf4a4c352e5e5fe698e to your computer and use it in GitHub Desktop.
SQL Collection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Dupplicate Table's Structure | |
| Create table abc select * from def limit 0; | |
| # Copy Table structure and Data | |
| Create table `bf_products_weekly_featured` select * from `bf_products_inventory` WHERE `in_shops` = 'bf_products_weekly_featured' limit 10; | |
| #Select Random record (in huge table) | |
| SELECT name | |
| FROM random AS r1 JOIN | |
| (SELECT CEIL(RAND() * | |
| (SELECT MAX(id) | |
| FROM random)) AS id) | |
| AS r2 | |
| WHERE r1.id >= r2.id | |
| ORDER BY r1.id ASC | |
| LIMIT 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment