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

  • Home
  • SEARCH
  • 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 6097263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:01:24+00:00 2026-05-23T13:01:24+00:00

Help a sqlite n00b out, please. I have two tables CREATE TABLE students (

  • 0

Help a sqlite n00b out, please.

I have two tables

   "CREATE TABLE students (" +
          "_id       INTEGER PRIMARY KEY AUTOINCREMENT," +
          "studentname      TEXT not null," +
          "studentpic       BLOB," +
          "comment          TEXT);";

and

   "CREATE TABLE classes (" +
           "_id              INTEGER PRIMARY KEY AUTOINCREMENT," +
           "classname        TEXT," +
           "attend           INTEGER," +
           "late             INTEGER," +
           "dtime            TEXT," +
           "student          INTEGER REFERENCES students(_id) on
                             UPDATE CASCADE);";

I want to display a list of students in particular class, but my classes table only reference them by student-id, how can I construct a query to pull back into a single cursor all the fields of ‘classes’ table but use the actual names from ‘students’ table ?

Many thanks in advance

  • 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-05-23T13:01:25+00:00Added an answer on May 23, 2026 at 1:01 pm

    You can use the rawquery method with the following SQL code:

    SELECT classes._id, students.studentname, classes.classname, classes.attend, classes.late, classes.dtime
    FROM students, classes
    WHERE students._id=classes.student
    

    In short, by selecting from two tables, you join them, but you have to specify how they are joined. The part after the SELECT tells what you want as your output. The FROM shows which tables are involved (whether or not the parts of those tables are shown in the output). By default, if you give it two tables, all possible combinations of one row from the first table and one from the second are created, so you need a criteria in the WHERE clause which narrows it down to only match up the rows from the students table with the corresponding row in the classes table with the matching id. This works whether or not there is a foreign key relationship defined.

    If you have additional criteria for the WHERE clause, you can add this by using AND. For example:

    WHERE students._id=classes.student AND classes.classname="Underwater Basket Weaving"
    

    There’s a good tutorial on the overall process of setting up and using databases in SQLite in Android (much of which you already seem to understand) here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

HELP! I just setup a virtual host for two sites that have a lot
Please help! Background info I have a WPF application which accesses a SQL Server
I use sqlite(3.7.4) in iphone. I create a table like: create table A (UserName
I have SQLite table with columns id and name. I return array of those
Help! I have an Axis web service that is being consumed by a C#
Help! I have a PHP (PHP 5.2.5) script on HOST1 trying to connect to
help me to manage IIS (what i am trying to do is create virtual
Please help! I'm really at my wits' end. My program is a little personal
Can someone help me convert this sqlite query to a postgres query? SELECT count(*),
Having a few problems with Ormlite and Android/Sqlite so any help appreciated. The database

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.