简体   繁体   English

显示相关记录vb.net mysql

[英]displaying related records vb.net mysql

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" 1)这里“ name_1”人是“ 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. 我想要的是,如果我搜索“ acct_no” 1,则其他关联帐户的所有详细信息也应显示为grind或其他内容。

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 -编辑-(1)我提出这个问题,但我不这样做,它可以解决我的问题。SQL:显示与通用ID相关的所有记录

(2) i forgot to mention that the database will store some of the fields in UTF format (some local language !) (2)我忘了提到数据库将以UTF格式(某些本地语言!)存储某些字段。

Use FIND_IN_SET function: 使用FIND_IN_SET函数:

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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM