
hai sir,
Can we write two SelectQueries in java application.i have two tables in database i.e tblsubbmission and tblgeneralinformation.In one jsp form I have to get the data form tblsubbmission and Some of the data from tblgeneralinformation.So, can we write Two select Queries in one application .please help me.
Thanks For Before Answeres You have Helped me alot . thanks for ur cop-oration Reply me as soon as possible

Hi Friend,
You can use two tables in one select query.
Here is an example:
<%@page import="java.sql.*"%>
<table border=1>
<tr><th>EMP NAME</th><th>EMP DEPT</th></tr>
<%
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from emp e,dept d where e.DEPT_NO=d.DEPT_NO");
while(rs.next()){
%>
<tr><td><%=rs.getString("e.EMP_NAME")%></td><td><%=rs.getString("d.DEPT_NAME")%></td></tr>
<%
}
rs.close();
st.close();
con.close();
}
catch(Exception e){}
%>
</table>
Create table emp
CREATE TABLE `emp` (
`EMP_NO` int(10) NOT NULL auto_increment,
`EMP_NAME` varchar(100) default NULL,
`DESIGNATION` varchar(100) default NULL,
`JOINING_DATE` date default NULL,
`SALARY` int(100) default NULL,
`DEPT_NO` int(100) default NULL,
PRIMARY KEY (`EMP_NO`)
)
Create table dept
CREATE TABLE `dept` (
`DEPT_NO` int(100) default NULL,
`DEPT_NAME` varchar(255) default NULL
)
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.