不过对于你这样的要求,mysql还是有支持的机制的
字段值用英文逗号分隔,比如‘未分组,VIP会员,广东客'
查询时select * from `table_a` where id=20 and find_in_set('未分组', group_name)
因为是原生支持的做法,mysql会对其进行优化
CREATE TABLE test_exp (id INT,
name varchar(6),
year INT,
other INT
)
INSERT INTO test_exp VALUES(1, '张三', 1991, 1)
INSERT INTO test_exp VALUES(2, '李四', 1992, 3)
INSERT INTO test_exp VALUES(3, '王五', 1993, 5)
INSERT INTO test_exp VALUES(4, '赵六', 1994, 6)
select id, name, year
INTO OUTFILE 'f:/test_exp.txt'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY ''''
LINES TERMINATED BY '\r\n'
FROM test_exp
输出文件内容如下:
1,'张三',1991
2,'李四',1992
3,'王五',1993
4,'赵六',1994
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)