displaying related records vb.net mysql

46 views Asked by At

i have some strange searching criteria. first let me clarify it,

i have a table like this

     acct_no |   name  | connected_acct
  ----------------------------------
  1          |  name_1 | 5,6,7
  2          |  name_1 | 11,12,13
   ---------------------------------

1) here person "name_1" is the holder of all the account of "5,6,7"

what i want is, if i search for "acct_no" 1, then all the details of other connected accounts should also be displayed in a grind or whatever.

Thanks

--EDIT-- (1) i fount this question but i don't this it can solve my problem SQL: Display all the records related to common id

(2) i forgot to mention that the database will store some of the fields in UTF format (some local language !)

1

There are 1 answers

1
Saharsh Shah On BEST ANSWER

Use FIND_IN_SET function:

Try this:

SELECT b.acct_no, b.name 
FROM accounts a 
INNER JOIN accounts b ON FIND_IN_SET(b.acct_no, a.connected_acct) 
WHERE a.acct_no = 1;