其中仅适用于许多列
但找不到我的确切用例
我尝试查看类似的问题, 以下内容:
GPCUST.DISPUTET,
> GPCUSTEXT.FIELD_VALUE WHERE METAFIELD_ID = '11',
> GPCUSTEXT.FIELD_VALUE WHERE METAFIELD_ID = '12',
> GPCUSTEXT.FIELD_VALUE WHERE METAFIELD_ID = '13',
FROM GPCOMP20.GPCUST
LEFT JOIN GPCOMP20.ARCUST ON GPCUST.CUSTNO=ARCUST.CUSTNO
RIGHT JOIN GPCOMP20.GPCUSTEXT ON GPCUST.CUSTNO=GPCUSTEXT.CUSTNO
WHERE GPCUST.COMPANY IS NOT NULL
因此,3列之后的条款全部gpcustext.field_value
仅适用于该精确的列,从而为每个列提供了不同的数据。就目前而言,它给了我每个条款背后的逗号下的红色错误线,说“附近的语法不正确”,“因此,我试图做的一定是错误的。
我正在使用Azure Data Studio,而我们的服务器是Microsoft SQL查询(我相信这对我上述编码的方式有所不同吗?)。
任何帮助将不胜感激!
edit
gpcustext桌子在搜索一个特定的custno时看起来如下:
custno | field_value | metafield_id |
---|---|---|
12345 | value 1 | 11 |
12345 | value 2 | 12 |
12345 | value3 value3 value3 | 13 |
我要尝试的结果,所以我尝试的结果是我尝试的结果要编译应在下面看起来像同一custno:
Custno | Disputet | Field_value | Field_value | field_value |
---|---|---|---|---|
12345 | 100.00 | value1 | value2 value2 | value3 |
I've tried looking at similar questions but couldn't find my exact use case, apologies if this is a duplicate (knowing how big this website is it probably is so sorry!)
I'm completely new to SQL and have managed to put the following together:
GPCUST.DISPUTET,
> GPCUSTEXT.FIELD_VALUE WHERE METAFIELD_ID = '11',
> GPCUSTEXT.FIELD_VALUE WHERE METAFIELD_ID = '12',
> GPCUSTEXT.FIELD_VALUE WHERE METAFIELD_ID = '13',
FROM GPCOMP20.GPCUST
LEFT JOIN GPCOMP20.ARCUST ON GPCUST.CUSTNO=ARCUST.CUSTNO
RIGHT JOIN GPCOMP20.GPCUSTEXT ON GPCUST.CUSTNO=GPCUSTEXT.CUSTNO
WHERE GPCUST.COMPANY IS NOT NULL
So the 3 WHERE clauses after the 3 columns that are all GPCUSTEXT.FIELD_VALUE
only apply to that exact column thus bringing in a different piece of data for each. As it stands it's giving me a red error line under the comma behind each clause saying " incorrect syntax near "," " so it must be wrong the way I'm trying to do it.
I'm using Azure Data Studio and our server is Microsoft SQL Query (I believe this makes a difference to the way I code above?).
Any help would be greatly appreciated!
EDIT
The GPCUSTEXT table looks as follows when searching on one particular CUSTNO:
custno | field_value | metafield_id |
---|---|---|
12345 | value1 | 11 |
12345 | value2 | 12 |
12345 | value3 | 13 |
So the result of my query I'm trying to compile should look like below for this same custno:
custno | disputet | field_value | field_value | field_value |
---|---|---|---|---|
12345 | 100.00 | value1 | value2 | value3 |
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论