Link to home
Start Free TrialLog in
Avatar of srikotesh
srikotesh

asked on

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
Avatar of Kanti Prasad
Kanti Prasad

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;
Avatar of srikotesh

ASKER

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
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?
ASKER CERTIFIED SOLUTION
Avatar of srikotesh
srikotesh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi

So I assume you are fine then ...
yes