I have this query:
query = "SELECT DISTINCT set_number " +
"FROM next_workout_exercises " +
"WHERE next_id = " + workoutid + " AND exercise_number = " + exercise_number;
and it returns some results.
After this, I have another query as follows:
query = "SELECT * FROM (SELECT * FROM next_workout_exercises INNER JOIN exercises WHERE next_workout_exercises.exercise_id = exercises.id )" +
" WHERE next_id = " + workoutid + " AND exercise_number = " + exercise_number + " AND set_number = " + set_number;
And this returns zero results SOMETIMES. The set_number is the same from the first query and no data has changed.
Can anyone comment why this might be happening?
The tables in question:
CREATE TABLE exercises
(
id INTEGER PRIMARY KEY,
exercise_name TEXT,
explanation TEXT,
type INTEGER,
target_body INTEGER,
exercise_video TEXT,
exercise_pic1 TEXT,
exercise_pic2 TEXT,
picturetype INTEGER,
backedup INTEGER
);
CREATE TABLE next_workout_exercises
(
id INTEGER PRIMARY KEY,
next_id INTEGER,
exercise_id INTEGER,
weightkg REAL,
weightlb REAL,
reps INTEGER,
reps2 INTEGER,
set_number INTEGER,
exercise_number INTEGER,
incrementkg REAL,
incrementlb REAL,
resttime1 INTEGER,
resttime2 INTEGER,
resttime3 INTEGER,
failures INTEGER,
failuresallowed INTEGER,
percentage REAL,
reptype INTEGER,
exercisetype INTEGER,
backedup INTEGER,
FOREIGN KEY(next_id) REFERENCES nextWorkout(id),
FOREIGN KEY(exercise_id) REFERENCES exercises(id)
);