List:MySQL++« Previous MessageNext Message »
From:Access-Dev Date:July 4 2011 1:40pm
Subject:Re: exception in subqueries
View as plain text  
Le 04/07/2011 13:02, Shaun Brown a écrit :
> 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

Thanks for replies.

For some reason , I ve got some problems running this query , it works 
fine with mysql query browser , but with mysqlpp I get the "id" in the 
numTags field

   mysqlpp::Query query = conn.query("SELECT SQL_CALC_FOUND_ROWS 
custom_tracking35.id AS numTags,custom_tracking35.id AS id 
,custom_tracking35.trackingID AS trackingID 
,trackingsessioninfo35.machineID AS machineID FROM custom_tracking35 
LEFT JOIN trackingsessioninfo35 ON custom_tracking35.trackingID = 
trackingsessioninfo35.trackingID GROUP BY custom_tracking35.trackingID 
ORDER BY custom_tracking35.id DESC LIMIT 0,50;");

if (mysqlpp::UseQueryResult res = query.use()) {

                                                while (row = 
res.fetch_row()) {

                                                      trackingSession t;
                                                      t.id          = 
MPP_TO_ITF_STRING( row[ "id" ]);
                                                      t.trackingID  = 
MPP_TO_ITF_STRING( row[ "trackingID" ] );
                                                      t.machineID   = 
MPP_TO_ITF_STRING( row[ "machineID" ] );
                                                      t.numTags     = 
MPP_TO_ITF_STRING( row[ "numTags" ]); //  numTags contains incorrect 
value , have to be the number of rows , but colum id returned
                                                      
Sessions.push_back( t );

                                                }
                                    }
                         }
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