Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access v5.2
  HXTT Cobol v2.1
  HXTT DBF v5.2
 
  Buy Now
  Support
  Download
  Document
  FAQ
  HXTT Excel v4.2
  HXTT Paradox v5.2
  HXTT Text(CSV) v5.2
  HXTT XML v1.2
Offshore Outsourcing
Oracle Data Import/Export
DB2 Data Import/Export
Sybase Data Import/Export
Free Resources
  Firewall Tunneling
  Search Indexing Robot
  Conditional Compilation
  Password Recovery for MS Access
  Password Recovery for Corel Paradox
  Checksum Tool for MD5
  Character Set Converter
  Pyramid - Poker of ZYH
   
   
   
Hongxin Technology & Trade Ltd. of Xiangtan City (abbr, HXTT)

HXTT DBF
LEFT JOIN not working
William Anthony
2007-06-22 19:30:49.0
select ckod.fkode_ac as CustID, ckod.fproduk as Product, ckod.fsls as Sales,
ifnull(targtoko.qty,0) as Qty, ifnull(targtoko.amt,0) as Amt
from "cpu-sls/cpu-mf/cuskod.cpu" as ckod LEFT JOIN "cpu-sls/targ_02.cpu" as targtoko
on targtoko.fkode_prd = ckod.fproduk and
targtoko.fkode_sls = ckod.fsls and
targtoko.fkode_ac = ckod.fkode_ac
where targtoko.annual =? and ckod.fsls =? and ckod.fproduk =?;

This query theoretically should return ALL CustID for specified Product and Sales.Qty, Amt returned if there are exists in targtoko table. But in my result, no rows returned.
Re:LEFT JOIN not working
William Anthony
2007-06-22 19:46:52.0
Note that above situation occur, when there are no rows in the targtoko table that match the WHERE condition.

I tried adding some rows in targtoko table that match the WHERE condition, the result mimics as I'm using INNER JOIN not LEFT JOIN.
Re:Re:LEFT JOIN not working
HXTT Support
2007-06-22 20:35:44.0
Checked.
>where targtoko.annual =?
Because you use that condition in WHERE clause, wich will result HXTT DBF to convert LEFT JOIN into INNER JOIN. Please remove that condition and try again.
Re:Re:Re:LEFT JOIN not working
William Anthony
2007-06-22 20:54:54.0
It has result now, but only partially.

The real result is 30 row. If I remove targtoko.annual =? from where clause, it only return the first 5 row.
Re:Re:Re:Re:LEFT JOIN not working
HXTT Support
2007-06-22 21:07:51.0
Try:
select ckod.fkode_ac as CustID, ckod.fproduk as Product, ckod.fsls as Sales from "cpu-sls/cpu-mf/cuskod.cpu" as ckod
where ckod.fsls =? and ckod.fproduk =?;

to see whether you can get 30 rows.
Re:Re:Re:Re:Re:LEFT JOIN not working
William Anthony
2007-06-22 21:31:04.0
Yes, completely 30 rows.
Re:Re:Re:Re:Re:Re:LEFT JOIN not working
HXTT Support
2007-06-23 04:54:14.0
Failed to recure your issue. If possible, you can zip and send your test sample to webmaster@hxtt.com
Re:Re:Re:Re:Re:Re:Re:LEFT JOIN not working
William Anthony
2007-06-24 18:51:31.0
I already sent it to you, please check it. Thanks
Re:Re:Re:Re:Re:Re:Re:Re:LEFT JOIN not working
HXTT Support
2007-06-24 19:05:17.0
Passed test. jdbc:dbf:/d:/test/lib/?DefaultExtension=CPU;DefaultNTXExtension=CPX

select ckod.fkode_ac as CustID, ckod.fproduk as Product, ckod.fsls as Sales, ifnull(targtoko.qty,0) as Qty, ifnull(targtoko.amt,0) as Amt from "cpu-sls/cpu-mf/cuskod.cpu" as ckod LEFT JOIN "cpu-sls/targ_02.cpu" as targtoko on targtoko.fkode_prd = ckod.fproduk and targtoko.fkode_sls = ckod.fsls and targtoko.fkode_ac = ckod.fkode_ac where ckod.fsls ='DK1' and ckod.fproduk ='01-OS' ;

will return 30 rows.
Re:Re:Re:Re:Re:Re:Re:Re:LEFT JOIN not working
William Anthony
2007-06-24 19:38:51.0
It's worked, but only if the parameter values is written with the SQL statement like your example, when I changed it to "ckod.fsls =? and ckod.fproduk =?" and using setObject function it will return to 5 rows.

Have you test it that way?
Re:Re:Re:Re:Re:Re:Re:Re:LEFT JOIN not working
HXTT Support
2007-06-24 19:57:09.0
Passed test too.

String sql;

sql="select ckod.fkode_ac as CustID, ckod.fproduk as Product, ckod.fsls as Sales, ifnull(targtoko.qty,0) as Qty, ifnull(targtoko.amt,0) as Amt from \"cpu-sls/cpu-mf/cuskod.cpu\" as ckod LEFT JOIN \"cpu-sls/targ_02.cpu\" as targtoko on targtoko.fkode_prd = ckod.fproduk and targtoko.fkode_sls = ckod.fsls and targtoko.fkode_ac = ckod.fkode_ac where ckod.fsls =? and ckod.fproduk =? ";

pstmt = con.prepareStatement(sql);

ParameterMetaData pmd=pstmt.getParameterMetaData();
for (int j = 1; j <= pmd.getParameterCount(); j++){
System.out.println(pmd.getParameterTypeName(j)
+ " "
+pmd.getParameterClassName(j)
);
}

resultSetMetaData = pstmt.getMetaData();
iNumCols = resultSetMetaData.getColumnCount();
for (int j = 1; j <= iNumCols; j++)
System.out.print(resultSetMetaData.getColumnLabel(j) + " ");

System.out.println();

pstmt.setObject(1,"DK1");
pstmt.setObject(2,"01-OS");
// pstmt.setString(1,"DK1");
// pstmt.setString(2,"01-OS");

rs = pstmt.executeQuery();

int count=0;
while (rs.next()) {
for (int j = 1; j <= iNumCols; j++) {
colval = rs.getObject(j) + "";
System.out.print(colval + " ");
}
System.out.println();
count++;
}
System.out.print("count: "+count);

rs.close();

pstmt.close();

Re:Re:Re:Re:Re:Re:Re:Re:LEFT JOIN not working
William Anthony
2007-06-24 22:06:48.0
I checked my code again and again, but still got nothing unusual. But it's OK, Thanks to your quick support, I will try another approach.

Search Key   Search by Last 50 Questions




Google
 

Address: 9 Station Rd., Xiangtan City, Hunan Province, P.R. China
Postcode: 411100
Phone: (86)731-58225727
Fax: (86)731-58225727
Email: webmaster@hxtt.com
Copyright © 1999-2011 Hongxin Technology & Trade Ltd. | All Rights Reserved. | Privacy | Legal | Sitemap