SQL:join和exists结合在一起 [英] SQL: join and exists are combined

查看:389
本文介绍了SQL:join和exists结合在一起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3张桌子。不相关的列被省略。

表1:项目

ID项目名称

1食品

2饮料
表2:发票

ID用户金额

1 1 20

2 1 30

表3 :Invoice_details

ID Invoice_id Items_id DetailsAmount

1 1 1 10

2 1 2 10

3 2 1 30


目标:

食物40

饮料10


我的查询:

I''ve got 3 tables. The irrelevant columns are omitted.
Table1:Items
ID ItemsName
1 Food
2 Beverage
Table2:Invoice
ID User Amount
1 1 20
2 1 30
Table3:Invoice_details
ID Invoice_id Items_id DetailsAmount
1 1 1 10
2 1 2 10
3 2 1 30

Aim:
Food 40
Beverage 10

My query:

展开 | 选择 | Wrap | 行号

推荐答案

单词Name是Access中的保留字。最好的解决方案是将字段名称更改为其他名称,例如ItemName。另一个不太理想的选择是将字段名称放在方括号中。
The word Name is a reserved word in Access. The best solution would be to change the field name to something else, like ItemName. Another, less desirable, option would be to place the field name in square brackets.
展开 | 选择 | Wrap | 行号


其实我的真实查询提及 ; PostNaam"而不是名称。出于简单和翻译的原因,我稍微改变了原始查询。为误解道歉。我相应地更新了我的问题。
Actually my real query mentions "PostNaam" instead of "Name". For reasons of simplicity and translation I changed the orginal query a bit. Apologies for the misunderstanding. I updated my question accordingly.


请复制并粘贴查询而不更改原始查询。此外,请在发布时使用代码标签( [CODE /] 按钮将为您添加)。
Please do a copy and paste of your query WITHOUT changing the original query. Also, please use code tags (the [CODE/] button will add them for you) when you post it.


这篇关于SQL:join和exists结合在一起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆