-1
+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |          |
|  7 | Muffy    |  24 | Indore    |          |
+----+----------+-----+-----------+----------+

値を挿入する際に、上記のテーブルの id 6,7 の給与列に空白の代わりに null を出力する方法。

 +----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |   null   |
|  7 | Muffy    |  24 | Indore    |   null   |
+----+----------+-----+-----------+----------+
4

2 に答える 2

1

RDBMS に応じて、SELECT で ISNULL() または IFNULL() を使用できます。クエリは次のようになります。

SELECT ID, NAME, AGE, ADDRESS, IFNULL(SALARY, "null") FROM YOURTABLE
于 2013-09-30T14:11:43.950 に答える
0

neelsgの答えに相当するOracle、

SELECT id, name, age, address, NVL(salary, "null") FROM yourtable
于 2013-09-30T14:56:04.760 に答える