求 Sql 语句怎么写! - .NET技术 / ASP.NET
有两张表
tb1 id name
01 张三
02 李四
tb2 id riqi renwu
01 2010.01.01 aaa
01 2010.02.02 bbb
02 2010.03.01 ccc
02 2010.04.02 ddd
我想得到下面的结果
01 张三 2010.01.01 aaa
02 李四 2010.03.01 ccc
也就是查询tb1表中所有的信息,并且将tb2表中最早的任务查询出来
下面是我的想法,但是and 后面的条件怎么写,
select tb1.id,tb1.name,tb2.riqi,tb2.renwu from tb1 left join tb2 on tb1.id=tb2,id and ?
select tb1.*, riqi from tb1 left join
(select min(riqi) as riqi from tb2 group by id) as tb2 on tb2.id = tb1.id
各位帮帮忙!!!!
条件只要让它们的主键相等
个人觉得干脆分两句写得了,这么写不累啊?
谢谢各位!!!
SQL code:
select t1.id, t1.name, t2.riqi, t2.renwu from @t1 t1, @t2 t2
where t1.id=t2.id and datepart(day, cast(riqi as smalldatetime))=1
再补一个,当然思路是一样的,我真不知道这个结果该用怎样的条件来限制,这个发帖时没说清。
SQL code
Co
相关问答:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jas ......
function CheckOpwd(){//验证用户名
var pwd=document.all.txtOpwd;
var div1=document.getElementById("divPwd");
if (pwd.value=="")
{
......
从数据库中查询一张表的数据
select 部门,姓名 from tb
如何才能生成下面的xml格式
XML code:
<folder state="unchecked" label="全部">
<folder state="unchecked&qu ......
就是一个按钮,点击之后打开对话框,然后选取图片。就这样上传。。
怎么实现。在网上搜到那么多的代码,全是很多的那种,不知道,看不下去。
所以在这里想请大哥大姐帮帮忙。
使用自带的fileupload控件可以实现 ......
1。怎样使xp_cmdshell能完整输出超过255个字符的字符串。
2。select 时,检索速度是与from后的 TABLE顺序有关,还是与where条件的顺序有关(TABLE数据多少 )
在系统属性设定里有个选项,可以修改单字段输出字数限制. ......