I have two table Table Doctor
docid|name|specialization|userid
1| amit|1|1
-----|-----|-|---|
2|sumit|2|1
-----|-----|-|---|
3|xyz |2|2
-----|-----|-|---|
3| xyzx |3|4
-----|-----|-|-- |
Table user
uid|fname|
---|-----|
1| aaa |
2| pppp|
3 | cccc|
Table specialization
sid|specialization|
-----|-----|
1| PHY|
-----|-----|
2| SUR|
-----|-----|
3| CARDEO|
and so on in all tabbles....
I want value like
uid|fname|PHY|SUR|CARDEO| dynamic specialization|
---|-----|-----|-----|-----|-----|
1 aaa| 1 |0|0|0|
---|-----|-----|-----|-----|-----|
2 ppp| 1 |1|0|0|
---|-----|-----|-----|-----|-----|
3 ccc| 0 |1|1|0|
I want user wise doctor specialization wise count for all users.