Hi everyone,
hopefully this is a really easy question (LOL are they ever?!)
I have a select statement as follows:
var sql = 'SELECT DISTINCT watchThreads.masterID, watchThreads.userID, threads.masterID, threads.forumID, threads.userID, threads.subject, threads.dateUpdated, threads.parentID, Threads.threadID FROM watchThreads, threads WHERE watchThreads.userID = '+ client.userID +' AND Threads.masterID = WatchThreads.masterID ORDER BY threads.dateUpdated DESC; '
This works fine, however, I also need it to only return the thread with the lowest unique threadID (from the Threads.threadID table and column).
At the moment, this select statement will pull back multiple threads that meet the query e.g. it will return one thread AND all responses to that thread. I just need the thread which has the lowest threadID value i.e. the original posting, not the responses.
Is there a way that you can specify in the select statement, that you only the threads with the lowest value?
I have googled it with no joy and not sure how to proceed, can anyone help please?
Hope that all makes sense and let me know if more info is needed (but i cant reply til back at work on monday).
Thanks in advance!!
hopefully this is a really easy question (LOL are they ever?!)
I have a select statement as follows:
var sql = 'SELECT DISTINCT watchThreads.masterID, watchThreads.userID, threads.masterID, threads.forumID, threads.userID, threads.subject, threads.dateUpdated, threads.parentID, Threads.threadID FROM watchThreads, threads WHERE watchThreads.userID = '+ client.userID +' AND Threads.masterID = WatchThreads.masterID ORDER BY threads.dateUpdated DESC; '
This works fine, however, I also need it to only return the thread with the lowest unique threadID (from the Threads.threadID table and column).
At the moment, this select statement will pull back multiple threads that meet the query e.g. it will return one thread AND all responses to that thread. I just need the thread which has the lowest threadID value i.e. the original posting, not the responses.
Is there a way that you can specify in the select statement, that you only the threads with the lowest value?
I have googled it with no joy and not sure how to proceed, can anyone help please?
Hope that all makes sense and let me know if more info is needed (but i cant reply til back at work on monday).
Thanks in advance!!