Complex select query

Forum for posting problems using QxOrm library

Complex select query

Postby ruddy32 » Fri Dec 10, 2010 1:20 pm

Hi,
I would like to create a complex SELECT query like this
Code: Select all
"SELECT count(*) FROM (SELECT id FROM t1 WHERE b != 0 LIMIT 10) AS q1 WHERE a = 10"
and
Code: Select all
"SELECT id FROM (SELECT id FROM t1 WHERE b = 'value1' LIMIT 10) AS q1 WHERE a = 'value2'"
.
How to run such query using qx::dao?
Thanks
ruddy32
 

Re: Complex select query

Postby QxOrm admin » Fri Dec 10, 2010 2:38 pm

Hi,

Today you cannot execute "complex query" with QxOrm (version 1.1.3).
You have to use directly QtSql module if QxOrm cannot resolve your problem, or execute more than 1 query.

However, QxOrm provides a mechanism to create "simple query" : the class qx::QxSqlQuery.
You can use the class qx::QxSqlQuery with :
- qx::dao::fetch_by_query(...)
- qx::dao::delete_by_query(...)
- qx::dao::count(...)

Here a example from the tutorial :
Code: Select all
   // Create a query to fetch only female author
   qx::QxSqlQuery query("WHERE author.sex = :sex");
   query.bind(":sex", author::female);

   list_author list_of_female_author;
   daoError = qx::dao::fetch_by_query(query, list_of_female_author);
QxOrm admin
 


Return to QxOrm - Help

Who is online

Users browsing this forum: No registered users and 10 guests