MySQLで完全に実行される次のクエリがありますが、MSSQLServerで実行すると問題が発生します。
SELECT failedlogins.*, siteprofiles.failedLogins AS max,
COUNT(failedlogins.id) AS total
FROM failedlogins RIGHT JOIN siteprofiles ON failedlogins > 0
WHERE computerName LIKE 'some awesome name' AND timeStamp > 1340752043
GROUP BY computerName
次のエラーが発生します。
Msg 8120, Level 16, State 1, Line 2
Column 'failedlogins.id' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Msg 8120, Level 16, State 1, Line 2
Column 'failedlogins.timeStamp' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Msg 8120, Level 16, State 1, Line 2
Column 'failedlogins.userName' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Msg 8120, Level 16, State 1, Line 2
Column 'siteprofiles.failedLogins' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
と関係があると思いますが、RIGHT JOIN
どうやって解決すればいいのかわかりません。
ちなみに、MySQLに慣れていない場合はsiteprofiles
、failedlogins
テーブルの唯一の行に直接参加しました。通常=
、複数のテーブルから2つの行が一緒に好きになるように表示されます。MySQLでは、テーブルに結合する行を1つだけ選択し、equals演算子を使用して行をリンクしない場合、返されるすべての行に行を結合します。
上記のステートメントのデバッグを手伝ってくれる人がいますか?
編集:
failedlogins
テーブルを構成するSQLは次のとおりです。
CREATE TABLE failedlogins (
"id" int NOT NULL,
"timeStamp" int NOT NULL,
"computerName" NTEXT NOT NULL,
"userName" NTEXT NOT NULL,
PRIMARY KEY ("id")
) ;
とsiteprofiles
テーブル:
CREATE TABLE siteprofiles (
"id" int NOT NULL,
"siteName" varchar(200) NOT NULL,
"paddingTop" tinyint NOT NULL,
"paddingLeft" tinyint NOT NULL,
"paddingRight" tinyint NOT NULL,
"paddingBottom" tinyint NOT NULL,
"width" int NOT NULL,
"height" int NOT NULL,
"sideBar" text NOT NULL,
"auto" text NOT NULL,
"siteFooter" text NOT NULL,
"author" varchar(200) NOT NULL,
"language" varchar(15) NOT NULL,
"copyright" varchar(200) NOT NULL,
"description" NTEXT NOT NULL,
"meta" text NOT NULL,
"timeZone" varchar(20) NOT NULL,
"welcome" text NOT NULL,
"style" varchar(200) NOT NULL,
"iconType" text NOT NULL,
"spellCheckerAPI" varchar(50) NOT NULL,
"saptcha" text NOT NULL,
"question" NTEXT NOT NULL,
"answer" NTEXT NOT NULL,
"failedLogins" int NOT NULL,
PRIMARY KEY ("siteName")
);
INSERT INTO siteprofiles (id, siteName, paddingTop, paddingLeft, paddingRight, paddingBottom, width, height, sideBar, auto, siteFooter, author, language, copyright, description, meta, timeZone, welcome, style, iconType, spellCheckerAPI, saptcha, question, answer, failedLogins) VALUES
(1, 'The Bell News Magazine', 0, 0, 0, 0, 260, 180, 'Right', '', '<p>© 2011 The Bell News Magazine</p>', 'The Bell News Magazine', 'en-US', '© 2011 The Bell News Magazine', 'The collaborative, innovative Bell News Magazine', 'The Bell News Magazine, The PAVCS Bell News Magazine, The Pennsylvania Virtual Charter School Bell News Magazine, Pennsylvania Virtual Charter School Bell News Magazine, Bell News Magazine, Bell News, Bell Magazine, The Bell Magazine, The Bell News', 'America/New_York', 'Ads', 'onlineUniversity.css', 'gif', 'jmyppg6c5k5ajtqcra7u4eql4l864mps48auuqliy3cccqrb6b', 'auto', '', '', 5);
お時間をいただきありがとうございます。