3

I have Two Table One to store Questions and Other to store Replies to Questions as Below

I have Shown the Table Structure and Column in table as Below

Question Table

 Question_Id(PK) | Question | Name | EmailAddress 

Answer Table

 Answer_Id | Question_Id | Question | Name | EmailAddress 

What ever question is posted it will be added to Question table and What ever Replies people post will be added to answer table

Now when ever Some one post a Reply to Question I Should Send mail to one who Posted Question and to those who posted Replies to the Question

Please Suggest a mysql Query for the above

Thank you

3 Answers 3

1

In theory you should know in the application the id of the question (qid) someone is replying to. Based on this id you can issue the following query:

Select EmailAddress from Question where Question_Id=qid Union Select EmailAddress from answer where Question_id=qid 

Depending on the logic of your application this might also select the address of the current user. If you want to avoid this you should include in both select statments a condition to exclude the current replier. Something like:

Select EmailAddress from Question where Question_Id=qid and EmailAddress!=curentUserAddress Union Select EmailAddress from answer where Question_id=qid and EmailAddress!=curentUserAddress 
Sign up to request clarification or add additional context in comments.

Comments

0
Select * from questions left join answers on questions.id = answers.question_id where question_id = 1 

Comments

0
select * from Question q, Answer a where q.Question_Id = a.Question_id and q.Question_Id = question_id 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.