简体   繁体   English

所需结果需要什么类型的连接

[英]What type is join is required for the desired result

I have two tables in mySQL:我在 mySQL 有两张表:

First table:第一张表:

(TABLE1)
Fruit + Shipn_Code +  Asmble_ID 
Apple |   .22      |    931   
Orange|   .22      |    931
Grape |   .22      |    931
Pear  |   .64      |    621 

Second table:第二张表:

(TABLE2)
Fruit +  Moved_By  +    My_Date
Apple |   110      |    2/17
Apple |   115      |    2/17
Apple |   119      |    3/1
Orange|   110      |    3/5
Grape |   120      |    3/7

The desired result is as follows想要的结果如下

(Desired Result from query)
Fruit +  110  +  115 +  119
Apple |   1   |   1  |   1
Orange|   1   |   0  |   0
Grape |   0   |   0  |   0

I am not sure how to query mySQL5.6 for the desired result.我不确定如何查询 mySQL5.6 以获得所需的结果。

Looks like you want to convert Table2 first two column data to Row based Matrix.看起来您想将 Table2 的前两列数据转换为基于行的矩阵。 You cannot do this using a single mysql query you may have to do this programmatically through a small script.您不能使用单个 mysql 查询来执行此操作,您可能必须通过一个小脚本以编程方式执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM