Thanks for the reply. Stats does contain 46 qids with sids of 7 there is one duplicate question now that i look harder in temp which is ok because 289 I forgot to mention that id in temp is not a key, this is because there is a test mode to ask random questions that aren't unique (so 289 was asked twice).
but if i did this SELECT Count() FROM Stats S LEFT JOIN Temp T ON T.Id = S.QuestionId WHERE S.SessionId = 7 Shouldn't only still return 46 rows and not 51 since stats in on the left and we are only getting associated data from the right? (Stats can contain multiple questionids also for the same session if ask unique was enable) Igor Tandetnik wrote: > > "Cnichols" <cnichol...@gmail.com> wrote > in message news:21676221.p...@talk.nabble.com >> 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 >> >> 51 results are returned? I do not understand why? > > Temp contains duplicate values in Id field. Or else, it's not true that > Stats contains 46 records with SessionId=7 - confirm by running > > SELECT COUNT() FROM Stats S > WHERE S.SessionId = 7; > > Igor Tandetnik > > > > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > -- View this message in context: http://www.nabble.com/INNER-JOIN%2C-JOIN-Confusin-tp21676221p21685825.html Sent from the SQLite mailing list archive at Nabble.com. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users