On 27/01/2009 12:00 PM, Cnichols wrote: > I have stumped myself with this sql goal. > > With this statement I am working with 3 tables > Stats - contains question asked history and if it was answered correcty > sessionid > questionid > correct > Questions - contains a list questions and mul choice answers and answer > id - pk > .... > ..... > etc. > Temp - schema is exactly like questions except contains missed questions > from a previous defined sessionid > > What i am trying to do right now is select the questions that have been > asked for the current session (ie 7) > Stats - contains 46 rows with sessionid of 7 > Temp - holds 52 missed questions from the previous session (6) > > example - this works perfect; it returns 46 results > ---------------- > SELECT COUNT() FROM Stats S > INNER JOIN Questions T ON S.QuestionId = T.Id > WHERE S.SessionId = 7 > > but if i do this > ---------- > SELECT COUNT() FROM Stats S > INNER JOIN Temp T ON S.QuestionId = T.Id > WHERE S.SessionId = 7
You said "Temp - holds 52 missed questions from the previous session (6)" so shouldn't the WHERE clause be: WHERE S.SessionId = 6 ? If not, change your query to do SELECT S.*, T.* FROM etc etc also select the 52 from Temp and work out which one is missing -- maybe a value of Temp.Id is wrong (i.e. doesn't match up with a value of Stats.QuestionId) > > 51 results are returned? I do not understand why? > HTH, John _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users