how to join the below queries into a single query

Hi Experts,

how do i join the below query
can any one suggest me

SELECT id,domain_id FROM `master` `t` WHERE domain_id!=0 AND customer_id=7 AND status=1 GROUP BY domain_id
o/p:357,42
42 i am placing in secondquery
357 i am placing in thirdquery



SELECT t.id FROM `master` `t` WHERE t.customer_id=7 AND status=1 AND t.domain_id=42 AND date(runtime) BETWEEN ("2014-06-01") AND ("2014-06-30")


SELECT t.task_id FROM `task` `t` WHERE t.id =357 ORDER BY id desc LIMIT 1

Thanks
LVL 2
srikoteshAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kanti PrasadCommented:
Hi

I am not sure about your table structure but try this

SELECT m.domain_id FROM master m  WHERE m.customer_id=7, m.domain_id IN( 357, 42 , !0) AND m.status=1  AND m.date(runtime) BETWEEN ("2014-06-01") AND ("2014-06-30") GROUP BY t.domain_id ORDER BY  t.domain_id
INNER JOIN task t
ON m.domain_id=t.task_id;
0
srikoteshAuthor Commented:
i will get the input of customer id and status first
based on customer id and status i am exectutiin first query
then i am getting the result as
domain id-42 and id as 357

i have to write a subquery first to get the result from first query then that value i have to add in second query and third

relation ship b/w table is
INNER JOIN task t
on m.id=t.def_id
0
Kanti PrasadCommented:
Hi

Can you please give me the output you are expecting and if possible the table names and the column values you have so that I can understand your query request better?
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

srikoteshAuthor Commented:
i have written the query

SELECT t.task_id FROM task as t inner join master as dm on m.id=t.def_id where t.customer_id=7 AND status=1 AND  date(runtime) BETWEEN ("2014-06-01") AND ("2014-06-30") and t.domain_id in (SELECT domain_id FROM `master` `t` WHERE domain_id!=0 AND customer_id=7 AND status=1 GROUP BY domain_id) ORDER BY id desc LIMIT 1
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Kanti PrasadCommented:
Hi

So I assume you are fine then ...
0
srikoteshAuthor Commented:
yes
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.

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.