SQL Query Help

Re: SQL Query Help

here’s the query. if you want it in a stored procedure, see http://dev.mysql.com/tech-resources…procedures.html and convert it.


  select tab1.username
      , tab1.surveryid
      , tab2.date
   from tab1
  left
   join tab2
     on tab2.username = tab1.username
        tab2.surveryid = tab1.surveyid 
  

but why is this in two different tables? there appears to be no need unless a user can take a survery more than once. and change the name of your date column to something else. using reserved words as column names is a bad idea.