mysql - 查询以从子表中获取不同的数据
问题描述
请提供查询以获取我的结果。
我有两个表如下。
price_band
id club_id name price
1 6 test 2.3
2 6 test1 3.3
price_band_seat
id price_band_id row seat block_id
1 1 a 1 1
2 1 a 2 1
3 1 b 1 2
4 2 b 2 2
and result that i want
Price block_id price_band_id row
2.3 1 1 a
2.3 2 1 b
3.3 2 2 b
查询排除 block_id 和 price_band_id 相同的原始数据。在哪里线索你必须采取 club_id=6
解决方案
请试试这个。
SELECT
DISTINCT
A.Price,B.block_id,B.price_band_id,B.row
FROM
price_band A
INNER JOIN price_band_seat B
ON A.id = B.price_band_id
WHERE A.club_id = 6
推荐阅读
- atom-editor - 如何更改 atom-live-server 默认浏览器
- python - TensorFlow v1.10+ 服务自定义估算器?
- r - 为什么我在 R 中得到这个混淆矩阵的错误?
- asp.net - web api POST 使用 AllowAnonymous Requests 返回 500 错误
- python - 如何应用带参数的条件装饰器?
- javascript - 如何在 Phaser 3 中将数据从场景传递到场景?
- php - 将 JSON 负载发送到 Google Cloud Task
- go - 在 gomail v2 中发送带有可选附件的电子邮件
- reactjs - 来自@material-ui labelWidth 的概述输入给出反应错误
- memory - 将字符串传递给 .wasm 模块