select cc_name from t_customer_company
where cc_id in (
SELECT c.cc_friend_ids
FROM t_project a, t_customer_company b, t_project_quotedprice c
WHERE a.p_id = c.p_id
and b.cc_id = c.cc_id
and a.user_id = 1;
)cc_friend_ids在数据库中是varchar类型的。数据像这样2,4,5
如子查询 SELECT c.cc_friend_ids
FROM t_project a, t_customer_company b, t_project_quotedprice c
WHERE a.p_id = c.p_id
and b.cc_id = c.cc_id
and a.user_id = 1;
的结果为2,3,4是个字符串
然后主查询本应该是这样的
select cc_name from t_customer_company
where cc_id in (
2,3,4
)但是每次都成了这样
select cc_name from t_customer_company
where cc_id in (
2
)
只会认到第一个id。求指点。
where cc_id in (
SELECT c.cc_friend_ids
FROM t_project a, t_customer_company b, t_project_quotedprice c
WHERE a.p_id = c.p_id
and b.cc_id = c.cc_id
and a.user_id = 1;
)cc_friend_ids在数据库中是varchar类型的。数据像这样2,4,5
如子查询 SELECT c.cc_friend_ids
FROM t_project a, t_customer_company b, t_project_quotedprice c
WHERE a.p_id = c.p_id
and b.cc_id = c.cc_id
and a.user_id = 1;
的结果为2,3,4是个字符串
然后主查询本应该是这样的
select cc_name from t_customer_company
where cc_id in (
2,3,4
)但是每次都成了这样
select cc_name from t_customer_company
where cc_id in (
2
)
只会认到第一个id。求指点。
解决方案 »
- postgres的自增类型字段的插入异常
- C++ 操作 MySQL 数据库效率低下问题(很低很低)
- 缺少更新或刷新的键列信息
- mysql5中如何查询出自增列的断号(被删掉的)
- ===狼哥帮我看下这个存储过程===
- mysql 复合索引和单列索引优缺点及什么情况下使用
- 解决Mysql 中文乱码高手帮帮忙
- Mysql经验足者,进来看看版本问题,select * from (select * from table) t1在Mysql3.23.56 for linux报错
- mysql存储过程文件是存在哪里的?
- 请帮忙看看有关IF函数的表达式怎么写~
- 请教:亿级数据量的单表的分区和索引建立方案
- 求一条sql语句,类似迭代?
where exists ( select 1 from FROM t_project a, t_customer_company b, t_project_quotedprice c
WHERE a.p_id = c.p_id
and b.cc_id = c.cc_id
and a.user_id = 1
and find_in_set(t.cc_id,c.cc_friend_ids)
)