I have two tables in my MySQL Server database with a common column:
Table1
+---------------------------------+
| columnA | columnB |
+---------------------------------+
| 123 | lorem |
| 456 | ipsum |
| 456 | dolor |
+---------------------------------+
Table2
+---------------------------------+
| columnA | columnC |
+---------------------------------+
| 123 | sit |
| 123 | amet |
| 123 | consectetur |
| 456 | adipiscing |
+---------------------------------+
I want to get all values of columnB
and columnC
where columnA
is 123
. The query I'm using is:
SELECT Table1.columnB, Table2.columnC
FROM Table1
INNER JOIN Table2 ON Table1.columnA = Table2.columnA
WHERE Table1.columnA = '123';
Here's the query result:
+---------------------------------+
| columnB | columnC |
+---------------------------------+
| lorem | sit |
| lorem | amet |
| lorem | consectetur |
+---------------------------------+
I'm getting the required results but i don't want these repetitive values as in columnB
in this example. Is there any way to replace (last two) redundant values lorem
with either NULL
or whitespace? Something like:
+---------------------------------+
| columnB | columnC |
+---------------------------------+
| lorem | sit |
| | amet |
| | consectetur |
+---------------------------------+