I have 2 table category and module. category table has 2 fields id & category module has 3 fields.id,modulename & catid
category table has 2 fields :
id & category
module has 3 fields:
id,modulename & catid
category
id | category
-----------------------------
1 | ABC
2 | PQR
module
id catid modulename
--------------------------
1 1 A
2 1 B
3 2 Q
4 2 P
I want to convert row to column and I'm getting a result like below:
ABC | PQR
-------------------
A | NULL
B | NULL
NULL | Q
NULL | P
and I want result like below (without null values)
ABC | PQR
-------------------
A | Q
B | P
this is my query
SELECT * FROM ( SELECT CASE WHEN category='ABC' THEN modulename ELSE '' END AS 'ABC', CASE WHEN category='PQR' THEN modulename ELSE '' END AS 'PQR' FROM category c INNER JOIN module m ON m.catid=c.id )t
but from this query i had null values, can u tell me how to avoid this null value?