Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8607697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:25:26+00:00 2026-06-12T03:25:26+00:00

How can I build a query in ORMLite so that I can use the

  • 0

How can I build a query in ORMLite so that I can use the orderBy function (using either the one with the raw string or the parametrized one) referencing an attribute of a different entity than the one of the dao I’m building the query from? My query is built like that:

// Inner query for performances
QueryBuilder<Performance, String> performancesQB = performanceDao.queryBuilder();
performancesQB.selectColumns("performance_id");
SelectArg performanceSelectArg = new SelectArg();
performancesQB.where().lt("date", performanceSelectArg);

// Outer query for Order objects, where the id matches in the performance_id
// from the inner query
QueryBuilder<Order, String> ordersQB = orderDao.queryBuilder();
ordersQB.where().isNull("user_id").and().in("performance_id", performancesQB);
ordersQB.orderByRaw("performances.date DESC");
pastOrdersQuery = ordersQB.prepare();

And the exception I’m getting whenever I try to execute this query is:

android.database.sqlite.SQLiteException: no such column: performances.date:,
   while compiling: SELECT * FROM `orders` WHERE
     (`user_id` IS NULL AND `performance_id` IN
     (SELECT `performance_id` FROM `performances` WHERE `date` < ? ) )
     ORDER BY performances.date DESC 

The only solution I see here is writing a raw query myself using a JOIN instead of a nested select. May this be a good solution?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T03:25:28+00:00Added an answer on June 12, 2026 at 3:25 am

    ORMLite now supports simple JOIN queries. Here the docs on the subject:

    http://ormlite.com/docs/join-queries

    So your query would now look something like:

    QueryBuilder<Performance, String> performancesQB = performanceDao.queryBuilder();
    SelectArg performanceSelectArg = new SelectArg();
    performancesQB.where().lt("date", performanceSelectArg);
    performancesQB.orderBy("date", false);
    
    // query for Order objects, where the id matches
    QueryBuilder<Order, String> ordersQB = orderDao.queryBuilder();
    ordersQB.join(performancesQB).where().isNull("user_id");
    pastOrdersQuery = ordersQB.prepare();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there anyway I can build a Select statement that uses the Contains function?
How can I build a query with this format with a sqlite3 database? CREATE
I am working on to build a query in MYSQL by which I can
I'm making a web site that users can build their TV watch list. They
Within a web project I am using jQuery and javascript to build a query
I can not build a query to mysql, to remove the lines from 200
Any Ideas how I can build the following query with the zend_db_table class? SELECT
Hello I know all about http://www.php.net/manual/en/function.http-build-query.php to do this however I have a little
I use this dynamic LINQ library together with Linq-to-Entities. I build query and after
How can I build a query statement like this: select * from men where

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.