我需要结合查看同一个表中的SELECT
语句的2个结果。
我的工作有效,但我确信有更好的方法可以做到。
SELECT
games._id,win.winner,deal.dealer
FROM
games,
(SELECT
players.name as winner
FROM
games, players
WHERE
players._id = games.winner
AND games._id = 2) AS win,
(SELECT
players.name as dealer
FROM
games, players
WHERE
players._id = games.dealer
AND games._id = 2) AS deal
WHERE
games._id = 2
感谢您帮助优化此查询。
编辑:
表的架构是:
CREATE TABLE games
(
_id INTEGER PRIMARY KEY,
winner integer,
dealer integer
)
CREATE TABLE players
(
_id INTEGER PRIMARY KEY,
name text
)
答案 0 :(得分:0)
下面的内容(未经测试的代码)应该有效:
protected override XmlReader GetReaderForMessage(SoapClientMessage message, int bufferSize)
{
var newStream = new MemoryStream();
var orgStream = message.Stream;
byte[] buf = new byte[bufferSize];
orgStream.Read(buf, 0, bufferSize);
string response = Encoding.UTF8.GetString(buf);
int pos = response.IndexOf("Response xmlns=");
if (pos == -1)
{
pos = response.IndexOf("Response>");
if (pos > -1)
response = response.Insert(pos + 8, " xmlns=\"http://tempuri.org/\"");
}
if (pos > -1)
{
int pos2 = pos + 8;
int pos3 = pos + 14;
while (response[--pos-1] != '<') ;
string tagName = response.Substring(pos, pos2 - pos);
response = response.Insert(pos3, ":ns2").Insert(pos, "ns2:");
int pos4 = response.IndexOf("</" + tagName) + 2;
response = response.Insert(pos4, "ns2:");
}
StreamWriter sw = new StreamWriter(newStream, Encoding.UTF8);
sw.WriteLine(response);
sw.Flush();
newStream.Position = 0;
return new System.Xml.XmlTextReader(newStream);
}