Home  >  Q&A  >  body text

mysql里concat函数和 ‘’|‘’ 符号一起用是表示什么?

比如像这种:concat(t4.name,t4.pinyin,t1.trader)|t4.name

PHPzPHPz2712 days ago1505

reply all(1)I'll reply

  • 天蓬老师

    天蓬老师2017-04-17 15:37:51

    concat is the mysql splicing function.

    "|" means bitwise OR. When performing a bitwise OR operation, the database system will first convert the decimal operands into binary numbers, and then perform a logical OR operation on the corresponding binary numbers bit by bit. If one or two of the corresponding binary bits are 1, the operation result of the bit is 1; otherwise, when the corresponding binary bit has two 0s, the operation result of the bit is 0.

    Example
    uses the bitwise OR operator "|" to perform operations. The SQL code is as follows:

    mysql>SELECT 10|15,9|4|2;
    As shown below:

    The operation effect of using the bitwise OR operator "|"

    The binary value of 10 is 1010, and the binary value of 15 is 1111. After bitwise OR operation, the result is 1111, and then the binary number 1111 is converted into a decimal number, which is the integer 15;

    The binary value of 9 is 1001, the binary value of 4 is 0100, and the binary value of 2 is 0010. After bitwise OR operation (first perform bitwise OR operation on 9 and 4, we get 1101, and then press it with 2 Bitwise OR operation, resulting in 1111), the result is 1111, and then the binary number 1111 is converted into a decimal number, which is the integer 15.

    Content excerpted from: http://www.baike369.com/conte...

    reply
    0
  • Cancelreply