use array/variable in sql-query

前端 未结 2 1820
忘了有多久
忘了有多久 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: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

提交回复
热议问题