use array/variable in sql-query

前端 未结 2 1821
忘了有多久
忘了有多久 2021-01-27 00:25

I\'m sure there is a way to do it but I don\'t know it anymore...

I have one big table with all the data.

In the table I have rows with information

相关标签:
2条回答
  • 2021-01-27 00:35

    you could try this: SELECT DISTINCT A.Groupname, B.name FROM tablename A JOIN tablename B ON A.GroupID = B.GroupID

    0 讨论(0)
  • 2021-01-27 00:43

    Try this:

    SELECT T2.name,T1.groupName
    FROM Table1 T1 INNER JOIN
    Table1 T2 on T1.groupID=T2.groupId2
    WHERE T2.category=1
    

    Result:

    NAME    GROUPNAME
    
    Paul    IT
    Bob     IT
    An      HR
    

    See result in SQL Fiddle

    0 讨论(0)
提交回复
热议问题