当前位置:首页
开发技术指南» 文章正文
    引言:
 

 

 ·数据库的判断更新问题    »显示摘要«
    摘要: 其中newid是数据库的自动编号类型,newsids是传来的id号: sqlq="update news set tp1=" & tm & " where "& clng(newsid)&"=" & clng(newsids) & "" 执行结果是没向数据库加入任......
    摘要: 关键是 好的住的地方 ,200元左右 ,最好不超过 300元。 有什么特色吃的 ,也可以推荐, 谢谢, ......


一个sql语句的写法,谢谢

表1  
  id       name       age  
  1           小张     22  
  2           小王     33  
   
  表2  
  id       name       age     mark  
   
  现在的要求是从表1中把记录写入表2,所的记录为  
  id       name       age       mark  
  1         小张       22         1小张22  
  2         小王       33         1小王33  
   
  关键就是最后一个字段的内容怎么得到,相当于字符串组合

NO.1   作者: pengdali

insert   表2   select   *,cast(id   as   varchar(10))+name+cast(age   as   varchar(10))   from   表1

NO.2   作者: letsflytogether

insert   into   表2   select   *,cast(id   as   varchar(3))+name+cast(age   as   varchar(3))   from   表1  
 

NO.3   作者: a1n1

insert   into   表2   select   *,cast(getdate()   as   carchar(10))+cast(id   as   varchar(3))+name+cast(age   as   varchar(3))   from   表1  
   
 

NO.4   作者: maoxianqiang

insert   into   表2   select   *,cast(year(getdate())   as   varchar(4))+  
                cast(Month(getdate())   as   varchar(2))+  
                cast(day(getdate())   as   varchar(2))   +  
                cast(id   as   varchar(5))+  
                name+  
                cast(age   as   varchar(3))   from   表1

NO.5   作者: letsflytogether

insert   into   表2   select   *,convert(char(8),getdate(),112)+cast(id   as   varchar(3))+name+cast(age   as   varchar(3))   from   表1


 ·怎样删除下面的主从表    »显示摘要«
    摘要: 有下面两主-从表 主表:linkman: linkmanid(pk) linkmanname 从表:ship: bookid(pk) bookname linkmanid(fk) 现在我想通过表:ship中的bookid删除表:linkman 要怎样写? 意思是:在从表中通过bookid找到linkmanid,再通过符合条件的linkmanid来删 除主表:linkman. 如果通......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE