表AAA中有字段xxname,xxpic,xxdate,xxlei,useid
表BBB中有字段xxusid,xxmonery,usid
现在想要得到结果是表AAA中xxlei=4,并且在表BBB中xxmonery
=2的前12条记录,其中表AAA中的useid与表BBB中的usid是对应的,我用下面的格式不对,请指点一下,我错在哪里,应该怎么写,谢谢。
sql= "select top 12 AAA.xxname,AAA.xxpic,AAA.xxdate,AAA.xxlei from AAA where xxlei=4 inner join BBB on AAA.useid=BBB.usid where BBB.xxmonery=2 order by AAA.xxdate desc "
------解决方案--------------------
select top 12 AAA.xxname,AAA.xxpic,AAA.xxdate,AAA.xxlei from (select * from AAA WHERE xxlei=4 ) AS AAA inner join BBB
on AAA.useid=BBB.usid where BBB.xxmonery=2 order by AAA.xxdate desc