表结构如下
表1: product_id        info
      0001               钢笔
表2: sell_id   product_id  total_number sell_time 
      0001      0001         10           2003-5-2我要选择记录集,需要将表2中的product_id变为对应的info,该怎么写呀select sell_id,product_id,total_number from 表2
               **********
有办法在一句SQL里实现吗
谢先

解决方案 »

  1.   

    select sell_id,info,total_number from 表2,表1 where 表2.product_id= 表1.product_id
      

  2.   

    bingo
    原来可以这样呀
    谢大侠了
      

  3.   

    还有一个问题select * from materiel_out where out_date=#2003-5#
    我用的SQLserver,原来用ACCESS时这样写没问题
    现在提示#附近有语法错误
    是不是SQLSERVE的日期型不能这样写呀万望指教
      

  4.   

    你可以将你的sql语句中的两个"#"都改为"'",你试一下
      

  5.   

    select * from materiel_out where out_date='2003-5-5'
      

  6.   

    select * from materiel_out where out_date='2002-01-01'
      

  7.   

    '将时间转化成SQLServer认可的形式
    Public Function ConvertTimeToSQLServerSQL(ByVal OriginalTime As Date) As String
        
        ConvertTimeToSQLServerSQL = "'" & Format(OriginalTime, "yyyy-mm-dd hh:nn:ss") & "'"
        
    End Function
    //
    dim strSQL as string 
    strSQL="select * from materiel_out where out_date=" & ConvertTimeToSQLServerSQL(#5/1/2003#)