0
votes

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.

1

1 Answers

0
votes

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