0

I have the following table in MySql Database:

enter image description here

I need to find out all the connected rows, wherever, a case_sno is exists in the club_case_sno column.

For example if someone search for case_sno = 10, it should retrieve the following result:

enter image description here

I need sql query which do the above.

Abdul Rahman
  • 1,669
  • 4
  • 24
  • 39

1 Answers1

0

May try:

SELECT * FORM tbl_sno WHERE (club_case_sno = 10 
OR case_sno IN 
 ( SELECT club_case_sno FROM tbl_sno WHERE case_sno = 10) 
OR club_case_sno IN 
 ( SELECT club_case_sno FROM tbl_sno WHERE case_sno = 10))
AND is_connected = 1
Riad
  • 3,822
  • 5
  • 28
  • 39
  • the query you provide can return the resultant record but there is an issue, what if i search for 795? it will return only two rows? while i need a recursive list of all the connected rows. in other words, if i search any of the value in the result set which returned by your query may be able to return all the connected rows from column to column. – Abdul Rahman Jan 15 '19 at 08:32