Skip to content

Instantly share code, notes, and snippets.

@MwBakker
Last active May 22, 2019 22:44
Show Gist options
  • Save MwBakker/8efa9932ab6d6160d35af5b18f6bcf1c to your computer and use it in GitHub Desktop.
Save MwBakker/8efa9932ab6d6160d35af5b18f6bcf1c to your computer and use it in GitHub Desktop.
// get all components belonging to a rack
@Query("SELECT c.id, cc.name as category_name, c.rack_id, c.component_category_id, c.name, c.img_path, c.code, " +
" (SELECT COUNT(c.name) " +
" FROM rack r " +
" WHERE c.rack_id = : rackID ) as count " +
"FROM component c " +
"INNER JOIN component_category cc ON cc.id = c.component_category_id " +
"WHERE c.rack_id = :rackID and cc.id = c.component_category_id " +
"ORDER BY c.name ASC")
LiveData<List<Component>> getRackComponents(long rackID);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment