2
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
正如你可以看到表1中包含CSV字符串。現在我需要從Table 1
中獲取id
s,其name
s存在於Table2
類型字段中。
有沒有這樣做的純粹的MySQL查詢方式?如果不是,那麼在大型記錄集的情況下,這樣做最省時的方式是什麼?
只是要確定,你要取消CONCAT的''每個name' table1'到行並做一個'where table1.name = table2.type'? – cctan 2012-03-30 07:09:45