sql语句 查询 - 其他数据库开发 / MySQL/Postgresql
SQL code:
select count(subid) as subnum,st.id,t.title,t.content from subtopics st JOIN topics t ON st.id=t.id
where st.id in (select id from topics where viewid='1')
group by st.id
我的链接条件 为t.id=st.id 但t.id对应的st.id有可能没没有 但我想显示t 表 的内容 SQL语句怎么写
select count(subid) as subnum,t.* from subtopics st right outer JOIN topics t ON t.id=st.id
where t.id in (select id from topics where viewid='1')
group by t.id
order by date desc
我也试出来了 还是谢谢大家 O(∩_∩)O~
相关问答:
从数据库中查询一张表的数据
select 部门,姓名 from tb
如何才能生成下面的xml格式
XML code:
<folder state="unchecked" label="全部">
<folder state="unchecked&qu ......
如何在SQL2005中设定定时作业,比如说定时清理某些表的数据,
或者是定时的将某些表的数据导出excel!
在线等待,急急急,最好是详细步骤!
之前我做的作业有点问题!
帮UP
参考:http://hi.baidu.com/toiota ......
字段1,字段2.....字段N,Status,ParentID
1,Name1....test1,1,99
1,Name1....test1,3,99
1,Name2....test2,1,101
1,Name2....test2,3,101
1,Name3....test3,2,101
1,Name1....test1,4,101
想要的结果是:
1,Na ......
我想查询出每天数据的最大的一个值。表的格式如下
表名: hisdata
字段 编号 值 状态 时间
Id value state dattime
101 32.3 0 ......