Rechercher dans le manuel MySQL

13.2.12 TABLE Statement

TABLE is a DML statement introduced in MySQL 8.0.19 which returns rows and columns of the named table.

  1. TABLE table_name [ORDER BY column_name] [LIMIT number [OFFSET number]]

The TABLE statement in some ways acts like SELECT. Given the existance of a table named t, the following two statements produce identical output:

  1.  

You can order and limit the number of rows produced by TABLE using ORDER BY and LIMIT clauses, respectively. These function identically to the same clauses when used with SELECT (including an optional OFFSET clause with LIMIT), as you can see here:

  1. mysql> TABLE t;
  2. +----+----+
  3. | a | b |
  4. +----+----+
  5. | 1 | 2 |
  6. | 6 | 7 |
  7. | 9 | 5 |
  8. | 10 | -4 |
  9. | 11 | -1 |
  10. | 13 | 3 |
  11. | 14 | 6 |
  12. +----+----+
  13. 7 rows in set (0.00 sec)
  14.  
  15. mysql> TABLE t ORDER BY b;
  16. +----+----+
  17. | a | b |
  18. +----+----+
  19. | 10 | -4 |
  20. | 11 | -1 |
  21. | 1 | 2 |
  22. | 13 | 3 |
  23. | 9 | 5 |
  24. | 14 | 6 |
  25. | 6 | 7 |
  26. +----+----+
  27. 7 rows in set (0.00 sec)
  28.  
  29. mysql> TABLE t LIMIT 3;
  30. +---+---+
  31. | a | b |
  32. +---+---+
  33. | 1 | 2 |
  34. | 6 | 7 |
  35. | 9 | 5 |
  36. +---+---+
  37. 3 rows in set (0.00 sec)
  38.  
  39. mysql> TABLE t ORDER BY b LIMIT 3;
  40. +----+----+
  41. | a | b |
  42. +----+----+
  43. | 10 | -4 |
  44. | 11 | -1 |
  45. | 1 | 2 |
  46. +----+----+
  47. 3 rows in set (0.00 sec)
  48.  
  49. mysql> TABLE t ORDER BY b LIMIT 3 OFFSET 2;
  50. +----+----+
  51. | a | b |
  52. +----+----+
  53. | 1 | 2 |
  54. | 13 | 3 |
  55. | 9 | 5 |
  56. +----+----+
  57. 3 rows in set (0.00 sec)

TABLE differs from SELECT in two key respects:

  • TABLE always displays all columns of the table.

  • TABLE does not allow for any arbitrary filtering of rows; that is, TABLE does not support any WHERE clause.

For limiting which table columns are returned, filtering rows beyond what can be accomplished using ORDER BY and LIMIT, or both, use SELECT.

TABLE can be used with temporary tables.

TABLE can also be used in place of SELECT in a number of other constructs, including those listed here:


Find a PHP function

Document created the 26/06/2006, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/mysql-rf-table.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.

References

  1. View the html document Language of the document:en Manuel MySQL : https://dev.mysql.com/

These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.

Contents Haut