mysql问题,关于left join和子查询的

surfchen 2005-05-27 08:08:10
select * from table1 where t1_c1 in (select * from table2 where t2_c=5) and t1_c2 in (select * from table3 where t3_c=5);
上面这句是否可用?(sorry,我目前无测试环境)
如果可用,如何改成用left join来表达?
...全文
494 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ice_berg16 2005-05-28
  • 打赏
  • 举报
回复
不能用left,用普通的就行了

select * from table1 t1,table2 t2, table3 t3
where t1.t1_c1 = t2.t2_c and t1.t1_c2=t3.t3_c and t2.t2_c=5 and t3.t3_c=5;
helloyou0 2005-05-28
  • 打赏
  • 举报
回复
似乎普通join就可以。

left join是当左表有,右表没有的时候也选择
surfchen 2005-05-28
  • 打赏
  • 举报
回复
还是自己搜索到了
就是left join两次,呵呵,居然能left join两次,刚知道~~
最近都在补MYSQL~~

我找到的解决方法在这里
http://cclinux2.stut.edu.tw/~ericfang/discus/detail.php?titleid=22
surfchen 2005-05-27
  • 打赏
  • 举报
回复
哦,我的SQL错了,改成这样的

select * from table1 where t1_c1 in (select t1_c1 from table2 where t2_c=5) and t1_c2 in (select t1_c1 from table3 where t3_c=5);

21,891

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧