How to retrieve numeric indexes from enum type values in MySQL

Example usage is like the following:

CREATE TABLE persons(
	id INT NOT NULL AUTO_INCREMENT,
	name CHAR(30) NOT NULL,
	surname CHAR(30) NOT NULL,
	gender ENUM('male','female','unisex') NOT NULL,
	PRIMARY KEY (id,gender)
);

INSERT INTO persons(name,surname,gender) VALUES('erman','gülhan','male'),('ayşe','dolu','female'),('ali','veli','male');

# this returns gender as string
SELECT name,gender FROM persons;

# this returns gender as numeric index
SELECT name,gender+0 FROM persons;

MySQL varsayılan karakter setini utf-8 ayarlama (how to set MySQL default character set to utf-8)

Veritabanına özel ayarlama

CREATE DATABASE mydb
 DEFAULT CHARACTER SET utf8
 DEFAULT COLLATE utf8_general_ci;

Sunucu açılışında belirleme

[mysqld]
init_connect='SET collation_connection = utf8_unicode_ci' 
init_connect='SET NAMES utf8' 
character-set-server=utf8 
collation-server=utf8_unicode_ci 
skip-character-set-client-handshake

MySQL yapılandırma zamanında belirleme

shell> ./configure --with-charset=utf8 --with-collation=utf8_general_ci

NOTLAR

HTML

HTML tarafında utf-8 desteği için:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />