How to make a SELECT in PHP/MySQL case insensitive?

前端 未结 7 908
面向向阳花
面向向阳花 2020-12-06 11:55

Her\'s my probleme, i guess its really basic.

I\'m trying to lookup in the database if a line does exist. heres my code :

$req=\"SELECT * FROM INSTIT         


        
7条回答
  •  温柔的废话
    2020-12-06 12:29

    It could also be a problem with your table COLLATE setting

    This CREATE statement will force your select queries to be case sensitive even when using LIKE operators:

    CREATE
      table instituts (inst_name VARCHAR(64))
      CHARACTER SET latin1 COLLATE latin1_general_cs;
    

    Whereas this one will ensure case-insensitivity:

    CREATE
      table instituts (inst_name VARCHAR(64))
      CHARACTER SET latin1
    

提交回复
热议问题