How to select with a binary field ? (php,mysql)

前端 未结 2 936
情歌与酒
情歌与酒 2021-01-19 05:30

Try to select use \"where\" clause in a mysql statement: e.g. Table: X with a ID column which is BINARY data type. Then save in a variable in php

$aid = $row         


        
相关标签:
2条回答
  • 2021-01-19 05:35

    Try below :

    add BINARY in where clause.

    $where = "where BINARY ID = '$aid'";
    $query = "SELECT * FROM X ".$where;
    
    0 讨论(0)
  • 2021-01-19 05:53

    Answering my own question.

    Just figured out:

    $where = "where HEX(ID) = 'bin2hex($aid)'";
    $query = "SELECT * FROM X ".$where;
    

    Does anyone know better solution?

    0 讨论(0)
提交回复
热议问题