Skip to content

Instantly share code, notes, and snippets.

@locvfx
Last active March 18, 2020 14:00
Show Gist options
  • Save locvfx/1f9106ab5dfe6bf4a4c352e5e5fe698e to your computer and use it in GitHub Desktop.
Save locvfx/1f9106ab5dfe6bf4a4c352e5e5fe698e to your computer and use it in GitHub Desktop.
SQL Collection
# 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