gpt4 book ai didi

tsql - SQL Join 语句问题

转载 作者:行者123 更新时间:2023-12-04 06:56:04 24 4
gpt4 key购买 nike

我试图从最新的 Cash 记录中获取所有字段,然后从相关的 TransactionInfo 记录中获取所有字段。我还不能让它正常工作:

select t.*, top 1 c.* from Cash c
inner join TransactionInfo t
on c.TransactionID = t.id
order by c.createdOn desc

最佳答案

那是什么top 1在那里做什么?如果您只想要一行,则 TOP(1) 必须排在第一位:

SELECT TOP(1) t.*, c.*
FROM Cash c
INNER JOIN TransactionInfo t
ON c.TransactionID = t.id
ORDER BY c.createdOn DESC

关于tsql - SQL Join 语句问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2560774/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com