SQL query with NOT IN

Results 1 to 4 of 4

Thread: SQL query with NOT IN

  1. #1
    jeps0 Guest

    Default SQL query with NOT IN

    I&#039;m trying to make a page index for my forum. There are two tables involved, "newthreads" and "replies", so therefor my SQL query is a little complicated:<BR><BR>SELECT newthreads.*, replies.repID, replies.ReplyOrder, replies.lvl, replies.repAuth, replies.repSubj, replies.repMsg, replies.repDatumtid, replies.repMember <BR>FROM newthreads <BR>LEFT JOIN replies ON newthreads.newID = replies.newID <BR>WHERE newthreads.newID NOT IN (SELECT TOP " & page*PerPage & " * FROM newthreads ORDER BY newID) <BR>ORDER BY newthreads.newID DESC, replies.ReplyOrder<BR><BR>Everything works fine, except the row starting with "WHERE newthreads.newID NOT IN...". page is the current page on the forum (duh), default value 0, and PerPage is the number of threads per page on the forum (currently 10).<BR><BR>What I&#039;m trying to do is selecting all posts except the [current page*10] first. This is my first time using NOT IN, so please don&#039;t kill me if this is easy.<BR><BR>/ jeps0

  2. #2
    Join Date
    Dec 1969

    Default NOT syntax error

    NOT is treated like a negative sign in math. It always goes in the front:<BR><BR>"WHERE NOT newthreads.newID IN..."

  3. #3
    Join Date
    Dec 1969

    Default NO I believe he is using it just right <eop