我有两张桌子: TWMWR和TWMWRemark。我有两个竞争标准,所以我试图单独运行查询然后加入它们。我试图在TWMWR中找到符合以下标准的所有记录:
PSWMS.TWMREMARK.TXT_REMARK LIKE '%Essential Equipment: N%'
AND PSWMS.TWMREMARK.TP_REMARK = '%CIS%'
然后我想获取WR列表(记录)并将其与另一个表连接以查找符合以下条件的记录:
PSWMS.TWMREMARK.ID_OPER = 'IXM0Q74'
AND PSWMS.TWMREMARK.TP_REMARK = 'CLM'
AND PSWMS.TWMREMARK.TXT_REMARK LIKE '%SOC%'
他们必须分开完成。有人可以帮忙吗?我粘贴了下面尝试的内容。我正在使用mySql开发人员。
SELECT PSWMS.TWMWR.CD_WR,
PSWMS.TWMWR.TP_JOB,
PSWMS.TWMWR.TS_OPER_RECORDED,
PSWMS.TWMWR.ID_CUSTOMER,
PSWMS.TWMREMARK.TS_REMARK,
PSWMS.TWMREMARK.ID_OPER,
PSWMS.TWMREMARK.TP_REMARK AS TP_REMARK1,
PSWMS.TWMREMARK.TXT_REMARK
FROM PSWMS.TWMWR
INNER JOIN PSWMS.TWMREMARK
ON PSWMS.TWMWR.CD_WR = PSWMS.TWMREMARK.CD_WR
WHERE PSWMS.TWMWR.TP_JOB = 'CLMDPD'
AND PSWMS.TWMWR.TS_OPER_RECORDED >= '21, Oct 2013'
AND PSWMS.TWMREMARK.ID_OPER = 'IXM0Q74'
AND PSWMS.TWMREMARK.TP_REMARK = 'CLM'
AND PSWMS.TWMREMARK.TXT_REMARK LIKE '%SOC%'
GROUP BY PSWMS.TWMWR.CD_WR,
PSWMS.TWMWR.TP_JOB,
PSWMS.TWMWR.TS_OPER_RECORDED,
PSWMS.TWMWR.ID_CUSTOMER,
PSWMS.TWMREMARK.TS_REMARK,
PSWMS.TWMREMARK.ID_OPER,
PSWMS.TWMREMARK.TP_REMARK,
PSWMS.TWMREMARK.TXT_REMARK
INNER JOIN
SELECT PSWMS.TWMWR.CD_WR
FROM PSWMS.TWMWR
INNER JOIN PSWMS.TWMREMARK
ON PSWMS.TWMWR.CD_WR = PSWMS.TWMREMARK.CD_WR
WHERE PSWMS.TWMWR.TP_JOB = 'CLMDPD'
AND PSWMS.TWMWR.TS_OPER_RECORDED >= '21, Oct 2013'
AND PSWMS.TWMREMARK.TXT_REMARK LIKE '%Essential Equipment: N%'
AND PSWMS.TWMREMARK.TP_REMARK = '%CIS%' AS WR
ON PSWMS.TWMWR.CD_WR = WR.CD_WR, PSWMS.TWMREMARK.CD_WR = WR.CD_WR