Mysql部分
1 创建poll表,用于记录单选投票用户的数据
字段包括 id[ Autoincreace ] , ip , time , iid(用户选则的选项,int型)
写出create上述table的完整sql语句
drop table if exists poll;
/*==============================================================*/
/* Table: poll */
/*==============================================================*/
create table poll
(
id int unsigned not null auto_increment,
ip varchar(15) not null,
time datetime not null,
iid int not null,
primary key (id)
) 2 写出将一个选择2号选项的ip为127.0.0.1的用户在当前时间的投票记录到数据库的SQL
/**//*========================得到测试数据c: .txt=========*/
SELECT *
into outfile 'c: .txt'
FROM `testok`;
/**//*========================载入临时表=========*/
create TABLE phpinterview.testok(id int,ip varchar(15),time datetime,iid int);
LOAD DATA INFILE 'c: .txt'
into table testok;
/**//*=========================删除ip有重复的记录=========*/
delete A from testok A,(select ip from testok B group by ip having count(*) >1) B
where A.ip=B.ip
/**//*================统计每个投票选项的投票数==============================*/
select iid,count(*) from testok B group by B.iid