R
R. Choate
My problem, I think, is with "Mid([CSPCL4],7,2) AS CSPCL" shown below, but I'm not sure. If I just pick out any field from either
one of my tables and run a simple SQL on that field, it works fine. However, I've got to join these 2 tables, and I've got to add
criteria to restrict the records in my recordset. The formula shown as part of this SQL, is intended to extract the 7th and 8th
characters from a string, and match those 2 characters to the 2-character string of the CPCHG field in the other table. Again, my
connection is good and I've narrowed the problem down to this SQL. This query is actually run against an AS400 table, but I believe
my formula is the problem. Please help.
mySQL = SELECT CPRD.CPDESC, CUST.CCYCLE, CUST.CCMPNY, Mid([CSPCL4],7,2) AS CSPCL
FROM CPRD INNER JOIN CUST ON CPRD.[CPCST#] = CUST.CCMPNY
WHERE (((CUST.CCYCLE)="RW" Or (CUST.CCYCLE)="RR" Or (CUST.CCYCLE)="RC" Or (CUST.CCYCLE)="TR" Or (CUST.CCYCLE)="WR" Or
(CUST.CCYCLE)="SB" Or (CUST.CCYCLE)="SC" Or (CUST.CCYCLE)="ZB" Or (CUST.CCYCLE)="1" Or (CUST.CCYCLE)="2" Or (CUST.CCYCLE)="10" Or
(CUST.CCYCLE)="11" Or (CUST.CCYCLE)="12" Or (CUST.CCYCLE)="13" Or (CUST.CCYCLE)="14" Or (CUST.CCYCLE)="15" Or (CUST.CCYCLE)="16")
AND ((CUST.CCMPNY)="1" Or (CUST.CCMPNY)="3" Or (CUST.CCMPNY)="4" Or (CUST.CCMPNY)="5" Or (CUST.CCMPNY)="6") AND
((Mid([CSPCL4],7,2))=[CPCHG]))
one of my tables and run a simple SQL on that field, it works fine. However, I've got to join these 2 tables, and I've got to add
criteria to restrict the records in my recordset. The formula shown as part of this SQL, is intended to extract the 7th and 8th
characters from a string, and match those 2 characters to the 2-character string of the CPCHG field in the other table. Again, my
connection is good and I've narrowed the problem down to this SQL. This query is actually run against an AS400 table, but I believe
my formula is the problem. Please help.
mySQL = SELECT CPRD.CPDESC, CUST.CCYCLE, CUST.CCMPNY, Mid([CSPCL4],7,2) AS CSPCL
FROM CPRD INNER JOIN CUST ON CPRD.[CPCST#] = CUST.CCMPNY
WHERE (((CUST.CCYCLE)="RW" Or (CUST.CCYCLE)="RR" Or (CUST.CCYCLE)="RC" Or (CUST.CCYCLE)="TR" Or (CUST.CCYCLE)="WR" Or
(CUST.CCYCLE)="SB" Or (CUST.CCYCLE)="SC" Or (CUST.CCYCLE)="ZB" Or (CUST.CCYCLE)="1" Or (CUST.CCYCLE)="2" Or (CUST.CCYCLE)="10" Or
(CUST.CCYCLE)="11" Or (CUST.CCYCLE)="12" Or (CUST.CCYCLE)="13" Or (CUST.CCYCLE)="14" Or (CUST.CCYCLE)="15" Or (CUST.CCYCLE)="16")
AND ((CUST.CCMPNY)="1" Or (CUST.CCMPNY)="3" Or (CUST.CCMPNY)="4" Or (CUST.CCMPNY)="5" Or (CUST.CCMPNY)="6") AND
((Mid([CSPCL4],7,2))=[CPCHG]))