SQLserver2008R2で以下のSelectは通るがdeleteでは「キーワード 'AS' 付近に不適切な構文があります。」とのErrorが出ます。理由が分かれば教えてくれますか?
SQL
1select tb.* from tb_eSession as tb where tb.[ID] Not In 2(select TOP 1 ID from [tb_eSession] as tb1 where tb1.ses_uID = tb.ses_uID order by tb1.loginDate DESC)
SQL
1delete from [tb_eSession] as tb where tb.[ID] Not In 2(select TOP 1 ID from [tb_eSession] as tb1 where tb1.ses_uID = tb.ses_uID order by tb1.loginDate DESC)
追記 Table です
SQL
1create table [dbo].[tb_eSession] ( 2 ID int identity not null 3 , [ses_uID] int 4 , [loginDate] datetime default getdate() not null 5 , primary key (ID) 6);
回答2件
あなたの回答
tips
プレビュー