How to use in my application a SELECT statement that must return more than one record to show multiple values for a certain field (m:m relation)

前端 未结 3 1696
长情又很酷
长情又很酷 2021-01-27 10:50

I don\'t know if you got what I mean, but I\'ll try to explain it with an example.

Users Table

UsedId    UserName
--------  ----------
1         Mike
2           


        
3条回答
  •  孤城傲影
    2021-01-27 11:08

    Ikashef, as Tomalak said, suppressing the repeating name from each of the name/permissions rows is a "presentation-layer" issue, i.e. how you display data to your users.

    What you want to do is look at ADO.NET DataTable to get these rows back:

           Joe    1
           Joe    7
           Joe    8
           Tom    3
           Tom    7
           Tom    8
    

    The DataTable has a Rows property, which contains a collection of rows. You can iterate over (i.e. visit in turn) each DataRow in the Rows collection. So read up on ADO.NET DataTable object and on collections classes and on the "for each" syntax.

提交回复
热议问题