List:MySQL++« Previous MessageNext Message »
From:Shaun Brown Date:July 4 2011 11:02am
Subject:RE: exception in subqueries
View as plain text  
Couldn't you do that within a single query?

SELECT (COUNT(b.*) FROM Bar b WHERE b.Id = f.Id) AS `BarCount`, f.* FROM Foo f;

I've used this type of query a couple times without issues, I remember that the MySQL++
only stores 2 slots, 1 for the query and 1 for the error status (correct me if i'm
wrong).

So if you use this as a single query then it'd be stored and would then avoid you needing
to then run another query from the first results.

Cheers,
Shaun

> Date: Mon, 4 Jul 2011 12:54:57 +0200
> From: ml@stripped
> To: plusplus@stripped
> Subject: Re: exception in subqueries
> 
> 
> > "SELECT 1;" is not a sub-query.
> >
> > You don't need the semi-colon in your query, the API knows that the
> > end of the string is the end of the query.
> >
> > To chain together multiple queries in a single string you can separate
> > them with ';' and enable the mysqlpp::MultiStatementOption (see
> > http://tangentsoft.net/mysql++/doc/html/userman/tutorial.html#connopts)
> > but for a single query just use "SELECT 1" instead of "SELECT 1;"
> >
> > The examples in the mysql++ source distribution are useful, you should
> > review them and compare your failing code to the examples to find why
> > they work and yours doesn't. See
> > http://tangentsoft.net/mysql++/doc/html/userman/tutorial.html#examples
> >
> Sorry, my message was not clear enough, by subquery I mean excetuing a 
> query for each row
> 
> eg:
> 
> pseudocode
> 
> query = "SELECT * FROM table";
> 
> for each (row){
> 
>      subquery = "SELECT COUNT(*) FROM anothertable WHERE table_id= 
> TABLEID_FROM_MAINQUERY
> 
> }
> 
> 
> 
> -- 
> MySQL++ Mailing List
> For list archives: http://lists.mysql.com/plusplus
> To unsubscribe:    http://lists.mysql.com/plusplus?unsub=1
> 
 		 	   		  
Thread
exception in subqueriesAccess-Dev4 Jul
  • Re: exception in subqueriesJonathan Wakely4 Jul
    • Re: exception in subqueriesAccess-Dev4 Jul
      • RE: exception in subqueriesShaun Brown4 Jul
        • Re: exception in subqueriesAccess-Dev4 Jul
          • Re: exception in subqueriesWarren Young5 Jul
      • Re: exception in subqueriesJonathan Wakely4 Jul