Connecting Tech Pros Worldwide Forums | Help | Site Map

How can I use multiple query in a statement?

ntxsoft's Avatar
Newbie
 
Join Date: Dec 2007
Posts: 3
#1: Dec 10 '07
Hello everybody,
I have a problem while I am trying to execute multiple query in a statement.
My query like that
Expand|Select|Wrap|Line Numbers
  1. DROP TABLE IF EXISTS query;
  2. CREATE TEMPORARY TABLE query SELECT Separations.ID,Name,Separation_Method,OrganismID,Date,Image,Description 
  3. FROM Separations;
  4.  
  5. DROP TABLE IF EXISTS login;
  6. CREATE TEMPORARY TABLE login SELECT Separations.ID,Name,Separation_Method,OrganismID,Date,Image,Description FROM Separations WHERE ID IN (SELECT a.RowID FROM Access AS a INNER JOIN Groups AS g ON a.GroupID=g.ID INNER JOIN Members AS m ON m.GroupID=g.ID INNER JOIN Users AS u ON u.ID=m.UserID WHERE u.Email='null' UNION SELECT a.RowID FROM Access AS a INNER JOIN Groups AS g ON a.GroupID=g.ID WHERE g.Name='Guests');
  7.  
  8. SELECT * FROM query INNER JOIN login ON query.ID=login.ID;
The problem is when I use stat.executeQuery() this query, it returns null to ResultSet. But this sql query returns 15 rows when I execute in Mysql tool. How can I solve this problem?

JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#2: Dec 10 '07

re: How can I use multiple query in a statement?


You want the result set of the last query; you can execute the first queries using
the 'batch' facility (read the API docs) and execute the last one separately and
get the result set back.

kind regards,

Jos
ntxsoft's Avatar
Newbie
 
Join Date: Dec 2007
Posts: 3
#3: Dec 11 '07

re: How can I use multiple query in a statement?


Thanks a lot Jos. I solve problem with your help.
Reply