How can I use multiple query in a statement?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ntxsoft
    New Member
    • Dec 2007
    • 3

    #1

    How can I use multiple query in a statement?

    Hello everybody,
    I have a problem while I am trying to execute multiple query in a statement.
    My query like that
    Code:
    DROP TABLE IF EXISTS query;
    CREATE TEMPORARY TABLE query SELECT Separations.ID,Name,Separation_Method,OrganismID,Date,Image,Description 
    FROM Separations;
     
    DROP TABLE IF EXISTS login;
    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');
     
    SELECT * FROM query INNER JOIN login ON query.ID=login.ID;
    The problem is when I use stat.executeQue ry() 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
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    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

    Comment

    • ntxsoft
      New Member
      • Dec 2007
      • 3

      #3
      Thanks a lot Jos. I solve problem with your help.

      Comment

      Working...