0

I am using Mysql database, Below is one of my table,

enter image description here

I want get Route id from above table based on the busstop id. For example i will pass the bus top id as 9 and 11. So i have to get route id which falls under these two bus stops. same time i shouldn't get route id if any one location is not exists. As in above table i shouldn't get 3 because 11 is not exists in that route 3. output as below

enter image description here Any suggestions are welcome. Regards Sangeetha

4
  • can't understand what do u want ? Commented May 16, 2015 at 5:42
  • Can you please paste your output also, so that we can help you out... For eg. if you entered bustopid as 9 & 11 then what output you exactly want... Commented May 16, 2015 at 6:19
  • Output is added to the question. Thank you.. Commented May 16, 2015 at 6:25
  • So the order in which stops occur is unimportant? 11,9 is the same as 9,11? Commented May 16, 2015 at 8:48

1 Answer 1

1

You can use post aggregation filtering to check for both conditions

SELECT routeid FROM t GROUP BY routeid
HAVING SUM(bustopid=9)>0
AND SUM(bustopid=11)>0
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.