gpt4 book ai didi

mysql - 枚举从显示表中检索到的结果

转载 作者:太空宇宙 更新时间:2023-11-03 11:21:42 24 4
gpt4 key购买 nike

我检索当前数据库中的所有表

#+begin_src sql :engine mysql :dbuser org :database grocer
show tables;
#+end_src

#+RESULTS:
| Tables_in_grocer |
|------------------|
| Customers |
| OrderItems |
| Orders |
| Products |
| Vendors |

如何将它们枚举为:

#+RESULTS:
| No. | Tables_in_grocer |
|-----+------------------|
| 1 | Customers |
| 2 | OrderItems |
| 3 | Orders |
| 4 | Products |
| 5 | Vendors |

最佳答案

试试这个查询:

  select @a:=@a+1 No, table_name
from your_schema.tables
(SELECT @a:= 0) AS a;

关于mysql - 枚举从显示表中检索到的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59173354/

24 4 0
文章推荐: java - 在 spring boot 中从 @Query View 返回 List