这种sql语句怎么写呀

soulland 2003-05-03 09:35:16
表结构如下
表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里实现吗
谢先
...全文
24 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
soulland 2003-05-03
  • 打赏
  • 举报
回复
还有一个问题select * from materiel_out where out_date=#2003-5#
我用的SQLserver,原来用ACCESS时这样写没问题
现在提示#附近有语法错误
是不是SQLSERVE的日期型不能这样写呀

万望指教
soulland 2003-05-03
  • 打赏
  • 举报
回复
bingo
原来可以这样呀
谢大侠了
robin_xin_xin 2003-05-03
  • 打赏
  • 举报
回复
select sell_id,info,total_number from 表2,表1 where 表2.product_id= 表1.product_id
w18ily 2003-05-03
  • 打赏
  • 举报
回复
'将时间转化成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#)
online 2003-05-03
  • 打赏
  • 举报
回复
select * from materiel_out where out_date='2002-01-01'
w18ily 2003-05-03
  • 打赏
  • 举报
回复
select * from materiel_out where out_date='2003-5-5'
qianhai 2003-05-03
  • 打赏
  • 举报
回复
你可以将你的sql语句中的两个"#"都改为"'",你试一下
soulland 2003-05-03
  • 打赏
  • 举报
回复
和视图有关系吗

怎么建
SeeSunSet 2003-05-03
  • 打赏
  • 举报
回复
建视图嘛.

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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