与子句一起存储临时数据:与oracle的等效语法是什么,但是在sqlite中?

发布于 2025-02-09 14:24:17 字数 417 浏览 2 评论 0 原文

在oracle中将临时数据存储在oracle中的语法看起来像是这样的:

with data (asset_id, x, y) as (
select 100, 10, 20 from dual union all
select 200, 30, 40 from dual union all
select 300, 50, 50 from dual)
select * from data

  ASSET_ID          X          Y
---------- ---------- ----------
       100         10         20
       200         30         40
       300         50         50

sqlite中的等效语法是什么?

The syntax for storing temporary data in the WITH clause looks like this in Oracle:

with data (asset_id, x, y) as (
select 100, 10, 20 from dual union all
select 200, 30, 40 from dual union all
select 300, 50, 50 from dual)
select * from data

  ASSET_ID          X          Y
---------- ---------- ----------
       100         10         20
       200         30         40
       300         50         50

What would be the equivalent syntax in SQLite?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

划一舟意中人 2025-02-16 14:24:17

在sqlite中,使用 value

with data (asset_id, x, y) as (
  VALUES
  (100, 10, 20),
  (200, 30, 40),
  (300, 50, 50)
)  
select * from data

参见

In SQLite it is simpler to use VALUES:

with data (asset_id, x, y) as (
  VALUES
  (100, 10, 20),
  (200, 30, 40),
  (300, 50, 50)
)  
select * from data

See the demo.

跨年 2025-02-16 14:24:17

看起来语法与Oracle相同,除了我们需要从dual 中删除

with data (asset_id, x, y) as (
select 100, 10, 20 union all
select 200, 30, 40 union all
select 300, 50, 50 )
select * from data

  ASSET_ID          X          Y
---------- ---------- ----------
       100         10         20
       200         30         40
       300         50         50

db<> fiddle

It looks like the syntax is the same as Oracle, except we need to remove from dual:

with data (asset_id, x, y) as (
select 100, 10, 20 union all
select 200, 30, 40 union all
select 300, 50, 50 )
select * from data

  ASSET_ID          X          Y
---------- ---------- ----------
       100         10         20
       200         30         40
       300         50         50

db<>fiddle

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文