DEV Community

Slava Rozhnev
Slava Rozhnev

Posted on

5 1

MySQL 8: short syntax for select all

Since MySQL 8 you can use pretty short query to select all data from table.
Just use TABLE a; instead SELECT * FROM a; and get same result

mysql> table a;
+===+===+
| m | n |
+===+===+
| 1 | 2 |
| 2 | 3 |
| 3 | 4 |
+---+---+

mysql> table b;
+===+===+
| m | n |
+===+===+
| 1 | 2 |
| 1 | 3 |
| 3 | 4 |
+---+---+

mysql> table c;
+===+===+
| m | n |
+===+===+
| 1 | 3 |
| 1 | 3 |
| 3 | 4 |
+---+---+
Enter fullscreen mode Exit fullscreen mode

The TABLE statement can be used with ORDER BY and LIMIT statements

mysql> table a order by n;
+===+===+
| m | n |
+===+===+
| 1 | 2 |
| 2 | 3 |
| 3 | 4 |
+---+---+

mysql> table b limit 2;
+===+===+
| m | n |
+===+===+
| 1 | 2 |
| 1 | 3 |
+---+---+

Enter fullscreen mode Exit fullscreen mode

This syntax also can be used with UNION statement

mysql> table a union all table b union all table c;
+===+===+
| m | n |
+===+===+
| 1 | 2 |
| 2 | 3 |
| 3 | 4 |
| 1 | 2 |
| 1 | 3 |
| 3 | 4 |
| 1 | 3 |
| 1 | 3 |
| 3 | 4 |
+---+---+
Enter fullscreen mode Exit fullscreen mode

SQLize.online - free online SQL environment

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (1)

Collapse
 
gbhorwood profile image
grant horwood •

i would actually use this!

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more