1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
drop table if exists listing;
set names utf8;
create table listing (
id int primary key auto_increment not null,
last_name char(30) not null,
first_name char(30) not null,
index name (last_name, first_name)
) default charset utf8;
show create table listing;
Table Create Table
listing CREATE TABLE `listing` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`last_name` char(30) NOT NULL,
`first_name` char(30) NOT NULL,
PRIMARY KEY (`id`),
KEY `name` (`last_name`,`first_name`)
) ENGINE=Mroonga DEFAULT CHARSET=utf8
insert into listing (last_name, first_name) values("Taro", "Yamada");
insert into listing (last_name, first_name) values("Taro", "Suzuki");
insert into listing (last_name, first_name) values("Jiro", "Yamada");
insert into listing (last_name, first_name) values("Taro", "Tanaka");
select * from listing;
id last_name first_name
1 Taro Yamada
2 Taro Suzuki
3 Jiro Yamada
4 Taro Tanaka
select * from listing where last_name = "Taro";
id last_name first_name
2 Taro Suzuki
4 Taro Tanaka
1 Taro Yamada
select * from listing where last_name = "Taro" and first_name = "Suzuki";
id last_name first_name
2 Taro Suzuki
select * from listing where last_name = "Taro" and (first_name >= "S" and first_name <= "Y");
id last_name first_name
2 Taro Suzuki
4 Taro Tanaka
drop table listing;
|