从左连接中的第二个表中选择字段

时间:2016-05-18 14:56:25

标签: sql

外部选择中的字段c.Mcc和c.Mnc没有填充,尽管我在bd中有这些字段:RawDebug.CarrierDetails。

任何帮助都将不胜感激。

 SELECT d.Id, d.DebugReason, d.DebugData, d.d1, d.d2, c.Mcc, c.Mnc
 FROM 
 (SELECT 
 Id, DebugReason, DebugData, 
 INTEGER(SUBSTR(DebugData,0,3)) AS d1, 
 SUBSTR(REGEXP_REPLACE(DebugData,'[^a-zA-Z0-9]',' '),4,LENGTH(DebugData)-3) as d2
 FROM TABLE_DATE_RANGE([bd:RawDebug.T],TIMESTAMP('2016-05-16'),TIMESTAMP('2016-05-16'))
 WHERE DebugReason = 50013 and Id = 550661626 LIMIT 50) AS d
 LEFT JOIN
 (
   SELECT Network, Mcc, STRING(Mnc) as Mnc from [bd:RawDebug.CarrierDetails]
 ) AS c
 ON c.Mcc = d.d1 and c.Mnc = d.d2
 LIMIT 50

1 个答案:

答案 0 :(得分:0)

如果结果中c.Mccc.MncNULL,但[bd:RawDebug.CarrierDetails]表中的值为ON c.Mcc = d.d1 and c.Mnc = d.d2,则唯一的解释是LEFT JOIN条件。您应该再次查看条件[bd:RawDebug.CarrierDetails]并确保这与a = [[741.0, 743.0, 3386.0, 284577.0, 290611.0, 300889.0, 305256.0, 917458.0, 917905.0, 917906.0, 922187.0, 925852.0, 1260021.0, 1377096.0, 1524210.0, 1680657.0, 1692571.0, 1692645.0, 1692647.0, 1713958.0, 1801008.0, 1818975.0, 1858888.0, 1880544.0, 1880898.0, 1880899.0, 1880900.0, 1881062.0, 1881073.0, 1881240.0, 1881433.0, 1881434.0, 1881435.0, 1881436.0, 1881438.0, 1958358.0, 1958478.0, 1958479.0, 1958481.0, 1967310.0], [0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]

中的数据完全匹配