0

I run the following query in mysql

UPDATE `gamequestions` SET a2 = '≠' WHERE id = 564

It runs successfully but the '?' is inserted in a2 field in place of '≠'

The datatype of a2 is text and also tried with varchar

Any Help greatly appreciated.

Garry
  • 595
  • 4
  • 19

4 Answers4

2

you need to change Collation to UTF-8 to store special characters

Bender
  • 705
  • 11
  • 25
  • 1
    Collation? There is no such thing as `UTF-8` collation. Are you sure you understand what `collation` is? – zerkms Apr 17 '14 at 04:20
1

insert ≠ (not equal to ) in mysql field

The goal in these conversions is always to decide on what charset/collation combination you want to use (UTF8 being the best choice in almost all scenarios) then to convert all tables/columns in your database to use that charset. At that point you can set DB_COLLATE and DB_CHARSET` to the desired charset and collation to match.

Note:

In most cases if a collation is not defined MySQL will assume the default collation for the CHARSET which is specified. For UTF8 the default is utf8_general_ci, which is usually the right choice.

Changing the default charset of the database

ALTER DATABASE MyDb CHARACTER SET utf8;

Changing the default charset of individual tables

ALTER TABLE MyTable CHARACTER SET utf8;

https://dev.mysql.com/doc/refman/5.1/en/charset-unicode-utf8.html

jmail
  • 5,944
  • 3
  • 21
  • 35
0

You can add that option in the /mysql/my.cnf. In the [mysqld] section add ’’character-set-server=UTF8"; in the [client] section add “default-character-set=UTF8”.

You can find more information in these links: http://dev.mysql.com/doc/refman/5.1/en/charset-http://dev.mysql.com/doc/refman/5.0/en/server-o

If you need to conver existing data, you can execute:

ALTER TABLE tbl_name CONVERT TO CHARACTER SET charset_name; 
underscore
  • 6,495
  • 6
  • 39
  • 78
  • It's a bad idea to rely on a mysql configuration, especially when it's possible to set on per-client basis. – zerkms Apr 17 '14 at 04:19
0

You need to check following things

use set names utf8 before you query/insert into the database

using Default CHARSET=utf8 when creating new tables

underscore
  • 6,495
  • 6
  • 39
  • 78
sshet
  • 1,152
  • 1
  • 6
  • 15