首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >mysql区分查询或分组查询

mysql区分查询或分组查询
EN

Stack Overflow用户
提问于 2015-10-30 15:46:02
回答 1查看 28关注 0票数 0

我有以下问题:-

代码语言:javascript
复制
Select
  PUB.oa_inthed.adcode As Address_Code,
  PUB.oa_intnom."due-date" As Commitment_Due_Date,
  PUB.oa_inthed.company As Company,
  PUB.oa_intnom.costcentre As Cost_Code,
  PUB.oa_inthed.currency As Currency,
  PUB.oa_inthed.description As Description,
  PUB.oa_inthed.docdate As Document_Date,
  PUB.oa_inthed."doc-id" As Document_Type,
  PUB.oa_intnom.expensecode As Expense_Code,
  PUB.oa_inthed.intid As Interface_Record_Key,
  PUB.oa_inthed.posted As "Posted?",
  PUB.oa_inthed.srcaccount As Source_Account,
  PUB.oa_inthed.docval As Value_Cur,
  PUB.oa_inthed.period As Period,
  PUB.oa_inthed.stat As Status
From
  PUB.oa_inthed Inner Join
  PUB.oa_intnom On PUB.oa_intnom.intid = PUB.oa_inthed.intid Inner Join
  PUB.oa_intextra On PUB.oa_intextra.intid = PUB.oa_intnom.intid
Where
  PUB.oa_inthed.company = 01 And
  PUB.oa_inthed.intid = 'XM618197%' And
  PUB.oa_intextra.rectype = 'REQHEAD'

并返回以下数据:

我如何才能为每个信息获得一个明确的行?

我正在使用MySQL。

欢迎所有建议

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-10-30 16:14:31

试试这个(未经测试):

代码语言:javascript
复制
SELECT PUB.oa_inthed.intid, 
    PUB.oa_inthed.adcode As Address_Code, 
    PUB.oa_intnom."due-date" As Commitment_Due_Date,
    PUB.oa_inthed.company As Company,
    PUB.oa_intnom.costcentre As Cost_Code,
    PUB.oa_inthed.currency As Currency,
    PUB.oa_inthed.description As Description,
    PUB.oa_inthed.docdate As Document_Date,
    PUB.oa_inthed."doc-id" As Document_Type,
    PUB.oa_intnom.expensecode As Expense_Code,
    PUB.oa_inthed.posted As "Posted?",
    PUB.oa_inthed.srcaccount As Source_Account,
    PUB.oa_inthed.docval As Value_Cur,
    PUB.oa_inthed.period As Period,
    PUB.oa_inthed.stat As Status
FROM PUB.oa_inthed
INNER JOIN PUB.oa_intnom 
ON PUB.oa_intnom.intid = PUB.oa_inthed.intid 
INNER JOIN PUB.oa_intextra 
ON PUB.oa_intextra.intid = PUB.oa_intnom.intid
INNER JOIN (
    SELECT PUB.oa_inthed.intid
    FROM PUB.oa_inthed
    GROUP BY PUB.oa_inthed.intid
) AS _aa
ON PUB.oa_inthed.intid = _aa.PUB.oa_inthed.intid
WHERE PUB.oa_inthed.company = 01 AND PUB.oa_inthed.intid = 'XM618197%' AND PUB.oa_intextra.rectype = 'REQHEAD'
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33439845

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档