Skip to content Skip to sidebar Skip to footer

Performing A Lookup On Sqlite

http://postimg.org/image/4vozphdk7/ So these are my tables; I save my data in such a way that the Workout_ID (second figure) references the Workout_ID in the top figure. What i ne

Solution 1:

A very simple JOIN can do that;

SELECT date_id, date, workout_name
FROM date_of_workout 
JOIN workout_table 
  ON date_of_workout.workout_id = workout_table.workout_id

Solution 2:

SELECT date_ID, date, workout_name
FROM workouts, dates
WHERE workouts.workout_ID = dates.workout_ID

Solution 3:

Updated Answer:

Try changing

Cursor c = ourDatabase.rawQuery("SELECT date_of_workout_id, date_of_workout, workout_name FROM DateofWorkout JOIN WorkoutTable ON DateofWorkout.name_of_workout = WorkoutTable.workout_id", null);

to

Cursor c = ourDatabase.rawQuery("SELECT date_of_workout_id, date_of_workout, workout_name FROM DateofWorkout JOIN WorkoutTable ON DateofWorkout.workout_id = WorkoutTable.workout_id", null);

the problem maybe is because you are comparing name_of_workout from workout_id.

A simple inner join perhaps?

select dow.date_id, dow.date, w.name
from workout w, date_of_workout dow
where w.workout_id = dow.workout_id

Post a Comment for "Performing A Lookup On Sqlite"