如何在mysql中将值与csv值进行比较? [英] How to compare a value with a csv value in mysql?

查看:65
本文介绍了如何在mysql中将值与csv值进行比较?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

表1

id(int) |  name(varchar)
1       |  at,bat
2       |  cat,at,bat,mat
3       |  mat,cat
4       |  sat,bat

表2

id(int)  |  type(varchar)
1        |  at
2        |  mat

您可以看到table1包含csv字符串.现在,我需要从Table2类型字段中存在nameTable 1中获取id.

As you can see table1 contains csv strings. Now I need to fetch the ids from Table 1 whose names exist in Table2 type field.

是否有任何纯mysql查询方式?如果没有,那么在大型记录集的情况下,最省时的方法是什么?

Is there any pure mysql query way of doing this? if not, what would be the most time efficient way of doing this in case of large record sets?

推荐答案

我会使用工作示例: http://sqlfiddle.com/#!2/b642c/4

这篇关于如何在mysql中将值与csv值进行比较?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆