有sql高手吗?能不能帮我看下这个sql语句

宝宝的笨熊 2011-04-26 11:38:16
有sql高手吗?能不能帮我看下这个sql语句又没有别的写法总感觉很怪!


select ms.uid,ms.lastip,mmc.username,mmc.extcredits4 from pre_common_member_status as ms left join (select m.uid,m.username,mc.extcredits4 from pre_common_member as m left join pre_common_member_count as mc on mc.uid=m.uid where m.uid='1439' and mc.uid is not null) as mmc on ms.uid=mmc.uid where m.uid='1439'
...全文
93 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
宝宝的笨熊 2011-04-26
  • 打赏
  • 举报
回复
学习了 谢谢 楼上朋友们帮我解答
TheGodOfGods 2011-04-26
  • 打赏
  • 举报
回复
都用inner join 不用判断空值

select ms.uid,ms.lastip,mmc.username,mmc.extcredits4
from pre_common_member_status as ms
inner join (
select m.uid
from pre_common_member as m
inner join pre_common_member_count as mc
on mc.uid=m.uid
where m.uid='1439'
) as mmc
on ms.uid=mmc.uid
SQL77 2011-04-26
  • 打赏
  • 举报
回复
select ms.uid,ms.lastip,m.username,mc.extcredits4
from pre_common_member_status ms
inner join pre_common_member m on ms.uid=m.uid
inner join pre_common_member_count mc on mc.uid=m.uid
where ms.uid='1439'
宝宝的笨熊 2011-04-26
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 ssp2009 的回复:]
SQL code
select ms.uid,ms.lastip,m.username,mc.extcredits4
from pre_common_member_status ms
left join pre_common_member m on ms.uid=m.uid
left join pre_common_member_count mc on mc.uid=m.uid
whe……
[/Quote]

我的写法存在不存在问题呢? 虽然结果是对的
宝宝的笨熊 2011-04-26
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 gamewong 的回复:]
能说明下想完成什么逻辑吗
[/Quote]


就是3张表 pre_common_member,pre_common_member_count,pre_common_member_status
需要查询 pre_common_member(username),
pre_common_member_count(extcredits4),
pre_common_member_status(lastip),
他们用一个共有的字段uid


我要查询出来的结果 :

uid lastip username extcredits4
1439 60.170.0.70 wodentt 984

想知道还有没有比我这样写简单的sql语句了

快溜 2011-04-26
  • 打赏
  • 举报
回复
select ms.uid,ms.lastip,m.username,mc.extcredits4
from pre_common_member_status ms
left join pre_common_member m on ms.uid=m.uid
left join pre_common_member_count mc on mc.uid=m.uid
where ms.uid='1439' and mc.uid is not null
testmelody 2011-04-26
  • 打赏
  • 举报
回复
把你的数据库字段贴出来看看,然后说下需求。你那个语句有问题~
GameWong 2011-04-26
  • 打赏
  • 举报
回复
能说明下想完成什么逻辑吗

34,837

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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