search

Home  >  Q&A  >  body text

php - How to replace null with the value of other fields in database table

There are two fields A in the data table class, field B
All of the fields in field A contain data, and some of the fields in field B contain data and some are NULL

Such as
A B
10 2
15 7
9 Null
16 8
7 Null
11 Null

How to make field B equal to the data of field A if it is NULL
That is to achieve the following effect
A B
10 2
15 7
9 9
16 8
7 7
11 11

曾经蜡笔没有小新曾经蜡笔没有小新2780 days ago756

reply all(2)I'll reply

  • 迷茫

    迷茫2017-05-18 10:47:16

    IF(expr1,expr2,expr3)
    IFNULL(expr1,expr2)
    case when
    Link description

    reply
    0
  • 为情所困

    为情所困2017-05-18 10:47:16

    ifnull(B,A)

    reply
    0
  • Cancelreply