package cn.com;
import java.sql.*;
public class Order {
public void TradeResult(String s){
Connection con;
PreparedStatement stmt;
ResultSet rs;
String sql="select (company.*)as经理人数 from (company.pos_id=position.pos_id and company.dept_id=deptment.dept_id) where pos_name=? group by dept_name";
try{
Class.forName("com.hxtt.sql.access.AccessDriver");
System.out.println("驱动成功...");
}catch(ClassNotFoundException e){
System.out.println("驱动失败..."+e);
String url="jdbc:access:///d:/mydb.mdb"; con=DriverManager.getConnection(url, "", "");
stmt=con.prepareStatement(sql); stmt.setString(1, s); rs=stmt.executeQuery();
System.out.println(rs);
stmt.close(); con.close();
}catch(SQLException e){
System.out.println("表名输入错误。"+e); }
}
}
你确定你单表就行了?
String sql="select * from company,position where(company.pos_id=position.pos_id and company.dept_id=deptment.dept_id) and pos_name=? group by dept_name";