两个有关数据库编程的问题,是高手的请进?!!!!!!!!!!!

明行 2001-08-19 03:01:48
1、在BCB中sal的日期格式为m/d/y,我已知年与月,要把表中所有的年与月与我已知的年与月相同的记录全列出来,完整的sql语名是怎么的?
2、在二个表中,一个有号码与名称,另一个有号码与金额(号码有重复),怎么将第一个表中的号码找到第二表中的对应的号码,并把号码,名称,金额全都列出来(号码,名称有重复).!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
...全文
4405 51 打赏 收藏 转发到动态 举报
写回复
用AI写文章
51 条回复
切换为时间正序
请发表友善的回复…
发表回复
zouyannan 2001-09-09
  • 打赏
  • 举报
回复
好经典!
TOKA 2001-09-09
  • 打赏
  • 举报
回复
1.Select * from mytable where datepart(year,[datecolname])=myyear and datepart(month,[datecolname])=mymonth
2.Select table1.id,table1.name,table1.account from Table1,table2 where Table1.id=table2.id
yueyue 2001-09-06
  • 打赏
  • 举报
回复
up
jackysoft2001 2001-09-05
  • 打赏
  • 举报
回复
先取出你要匹配的字符
再用SQL语句
ghibrain 2001-09-04
  • 打赏
  • 举报
回复
Q1:在SQL2000中查:FORMAT子句,可格式化日期字符串。
Q2:用master-detail
amengcat 2001-09-03
  • 打赏
  • 举报
回复
实现的时候要考虑效率!
另外,并不是你实现了你想要的结果就证明你的语句没有错误,
crycoming 2001-08-29
  • 打赏
  • 举报
回复
is it OK?
qianby 2001-08-27
  • 打赏
  • 举报
回复
关住
superct 2001-08-25
  • 打赏
  • 举报
回复
distinct一下
select distinct x.num,x.name from table1.dbf x,table2.dbf y
where x.num=y.num and x.num not in
(select num from table2.dbf where extract(year from date)=:valyear and extract
(month from date)=:valmonth group by num)
明行 2001-08-23
  • 打赏
  • 举报
回复
多谢大家!!!!!!!!!!!!!!!!!!!!!!!
KingSunSha 2001-08-23
  • 打赏
  • 举报
回复
select distinct x.num,x.name from table1.dbf x,table2.dbf y
where x.num=y.num and x.num not in
(select num from table2.dbf where extract(year from date)=:valyear and extract
(month from date)=:valmonth group by num)


or

select x.num,x.name from table1.dbf x,table2.dbf y
where x.num=y.num and x.num not in
(select num from table2.dbf where extract(year from date)=:valyear and extract
(month from date)=:valmonth group by num)
group by x.num, x.name
rmy 2001-08-23
  • 打赏
  • 举报
回复
多谢大家了,OK了,但是有又了新问题:
select x.num,x.name from table1.dbf x,table2.dbf y
where x.num=y.num and x.num not in
(select num from table2.dbf where extract(year from date)=:valyear and extract
(month from date)=:valmonth group by num)
最后得出:
num name
1 aaa
1 aaa
1 aaa
1 aaa
可是我只要一条记录呀。
请大家指教,多谢了!!!!!!!!!!!!!!!!!
lingyu2001 2001-08-23
  • 打赏
  • 举报
回复
看不懂
chenlp99 2001-08-23
  • 打赏
  • 举报
回复
T-Sql (Too easy)
1: Select * from YourTable
Where DateDiff(month , YouDateField , YouDate) = 0
2: Select a.Code ,a.Name ,b.Money
From Table1 a , Table2 b
Where b.Code = a.Code
勉励前行 2001-08-22
  • 打赏
  • 举报
回复
第一個問題:(T_SQL)
select * from Table
where year(DateTimeField) = :MyYear and month(DateTimeField) = :MyMonth
第二個問題:(ANSI_SQL)
select a.號碼,a.名稱,b.金額
from Table1 a,Table2 b
where a.號碼 = b.號碼
group by a.號碼,a.名稱,b.金額
order by a.號碼,a.名稱,b.金額
明行 2001-08-22
  • 打赏
  • 举报
回复
没有在机器上试过,回家试试再来,多谢大家!!!!!!!!!!!!!!!!!!!!!!!!
KingSunSha 2001-08-22
  • 打赏
  • 举报
回复
I don't know what you really want for the 2nd question. pls explain again.
明行 2001-08-22
  • 打赏
  • 举报
回复
请各位发挥......
程序猪
弱水三千
玉笛书生
都在什么地方呢?快来帮忙呀!!!!!!
请各位cfan转达.!!!!!!!!!!!!!!!!!!!!
rmy 2001-08-22
  • 打赏
  • 举报
回复
两个有关数据库编程的问题,是高手的请进?!!!!!!!!!!!
明行 2001-08-22
  • 打赏
  • 举报
回复
你们到什么地方去了.
加载更多回复(31)

1,178

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder 数据库及相关技术
社区管理员
  • 数据库及相关技术社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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