Thursday, June 22, 2023

List of 41 MySQL queries

 List of 41 MySQL queries

  1. SELECT * FROM table_name;
  2. SELECT column_name FROM table_name;
  3. SELECT COUNT(*) FROM table_name;
  4. SELECT MAX(column_name) FROM table_name;
  5. SELECT MIN(column_name) FROM table_name;
  6. SELECT AVG(column_name) FROM table_name;
  7. SELECT SUM(column_name) FROM table_name;
  8. SELECT DISTINCT column_name FROM table_name;
  9. SELECT column_name FROM table_name WHERE column_name = 'value';
  10. SELECT column_name FROM table_name WHERE column_name LIKE '%value%';
  11. SELECT column_name FROM table_name WHERE column_name BETWEEN 'value1' AND 'value2';
  12. SELECT column_name FROM table_name ORDER BY column_name ASC;
  13. SELECT column_name FROM table_name ORDER BY column_name DESC;
  14. SELECT column_name FROM table_name LIMIT 10;
  15. SELECT column_name FROM table_name LIMIT 10 OFFSET 5;
  16. SELECT column_name FROM table_name WHERE column_name IN ('value1', 'value2', 'value3');
  17. SELECT column_name FROM table_name WHERE column_name NOT IN ('value1', 'value2', 'value3');
  18. SELECT column_name FROM table_name WHERE column_name IS NULL;
  19. SELECT column_name FROM table_name WHERE column_name IS NOT NULL;
  20. SELECT column_name FROM table_name GROUP BY column_name;
  21. SELECT column_name, COUNT(*) FROM table_name GROUP BY column_name;
  22. SELECT column_name, AVG(column_name) FROM table_name GROUP BY column_name;
  23. SELECT column_name, SUM(column_name) FROM table_name GROUP BY column_name;
  24. SELECT column_name FROM table_name HAVING COUNT(*) > 10;
  25. SELECT column_name FROM table_name WHERE column_name IN (SELECT column_name FROM table_name2);
  26. SELECT column_name FROM table_name LEFT JOIN table_name2 ON table_name.column_name = table_name2.column_name;
  27. SELECT column_name FROM table_name RIGHT JOIN table_name2 ON table_name.column_name = table_name2.column_name;
  28. SELECT column_name FROM table_name INNER JOIN table_name2 ON table_name.column_name = table_name2.column_name;
  29. INSERT INTO table_name (column_namecolumn_name2) VALUES ('value1', 'value2');
  30. UPDATE table_name SET column_name = 'value1' WHERE column_name = 'value2';
  31. DELETE FROM table_name WHERE column_name = 'value1';
  32. CREATE TABLE table_name (column_name VARCHAR(255), column_name2 INT);
  33. DROP TABLE table_name;
  34. ALTER TABLE table_name ADD column_name VARCHAR(255);
  35. ALTER TABLE table_name DROP column_name;
  36. RENAME TABLE table_name TO new_table_name;
  37. SHOW TABLES;
  38. SHOW COLUMNS FROM table_name;
  39. SHOW CREATE TABLE table_name;
  40. EXPLAIN SELECT * FROM table_name;
  41. USE database_name; 4

No comments:

eLearning and Blackboard

  IT professional, U bring a unique set of skills and expertise that can greatly contribute to the successful development and implementati...