Count of other rows in table with the same value

前端 未结 2 1259
刺人心
刺人心 2020-12-22 03:37

So I\'m a bit new to mySQL and can figure out how to do this. I have a table with columns for worker, the building they work in, and the office they work in.

I\'m tr

2条回答
  •  佛祖请我去吃肉
    2020-12-22 03:56

    Try this:

    SELECT t1.*,
      (SELECT COUNT(1)
      FROM mytable t2
      WHERE t2.`room number` = t1.`room number`
      )
    FROM mytable t1
    

    I advice you don't use field name with white space, use the underscore instead white space.

提交回复
热议问题