Sql query, is there a more efficient way to write this

Is there a more efficient way to write this query?

<CFQUERY NAME="mailregister" DATASOURCE="register">
SELECT distinct register.name, register.odate, register.ipregister, register.fname, register.lname, register.email, register.logname, register.passwd, register.acceptp, register.seqid, register.searchb1, register.searchb2, register.searchb3, register.searchb4, register.searcha1, register.searcha2, register.searcha3, register.searcha4 from register, responselog
where register.logname=responselog.sentto and responselog.datesent = '#url.datesent#' and responselog.responsetype = 'TW' and register.acceptp = 'Yes' and responselog.readmessage = 'No'
</CFQUERY>
ondrejko1Asked:
Who is Participating?
 
rafranciscoCommented:
Try this:

SELECT distinct register.name, register.odate, register.ipregister, register.fname, register.lname,
       register.email, register.logname, register.passwd, register.acceptp, register.seqid, register.searchb1,
       register.searchb2, register.searchb3, register.searchb4, register.searcha1, register.searcha2, register.searcha3,
       register.searcha4
from register inner join responselog
                   on register.logname=responselog.sentto and
                      responselog.datesent = '#url.datesent#' and
                      responselog.responsetype = 'TW' and
                      register.acceptp = 'Yes' and
                      responselog.readmessage = 'No'
0
 
Renante EnteraSenior PHP DeveloperCommented:
Hi ondrejko1!

You can also try this one :

<CFQUERY NAME="mailregister" DATASOURCE="register">
SELECT distinct register.name, register.odate, register.ipregister, register.fname, register.lname, register.email, register.logname, register.passwd, register.acceptp, register.seqid, register.searchb1, register.searchb2, register.searchb3, register.searchb4, register.searcha1, register.searcha2, register.searcha3, register.searcha4
FROM register
INNER JOIN responselog
  ON responselog.sentto = register.logname AND responselog.datesent = '#url.datesent#' AND responselog.responsetype = 'TW' AND responselog.readmessage = 'No'
WHERE register.acceptp = 'Yes'
</CFQUERY>

Hope this helps you.  Just try it.


Goodluck!
eNTRANCE2002 :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.