Save the union query and then use it as the source for a make table query.
Very unusual to need to do this. Probably not a good idea, but I don't know
your data or why you would want to do this.
John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
pat67 said:
Nope, that is the behavior you see in a continuous form.
John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
pat67 wrote:
On Jul 31, 10:42 am, John W. Vinson
SELECT tblResults2.ID AS GameID, tblResults2.Date AS GameDate,
tblResults2.Player AS PlayerName, tblResults2.Home AS Team,
tblResults2.Result AS PlayerResult, tblResults2.Runout AS RO
FROM tblResults2
UNION ALL SELECT tblResults2.ID AS GameID, tblResults2.Date AS
GameDate, tblResults2.Player1 AS PlayerName, tblResults2.Away AS Team,
tblResults2.Result1 AS PlayerResult, tblResults2.Runout1 AS RO
FROM tblResults2;
I total with this query
SELECT qryUnion3.PlayerName, qryUnion3.Team,
Sum(IIf([PlayerResult]="w",1,0)) AS Won, Sum(IIf([PlayerResult]="l",
1,0)) AS Lost, Sum(IIf([RO]="x",1,0)) AS Runouts
FROM qryUnion3
GROUP BY qryUnion3.PlayerName, qryUnion3.Team;
Can i do that in one query?
You may need to consult MySQL documentation (or peer support, or whatever) to
find MySQL's syntax for Subqueries, but yes a subquery should work.. I'd omit
fields you're not using (game date frex) and try:
SELECT PlayerName, Team,
Sum(IIf([PlayerResult]="w",1,0)) AS Won, Sum(IIf([PlayerResult]="l",
1,0)) AS Lost, Sum(IIf([RO]="x",1,0)) AS Runouts
FROM [SELECT tblResults2.Player AS PlayerName, tblResults2.Home ASTeam,
tblResults2.Result AS PlayerResult, tblResults2.Runout AS RO
FROM tblResults2
UNION ALL SELECT tblResults2.Player1 AS PlayerName, tblResults2.Away AS Team,
tblResults2.Result1 AS PlayerResult, tblResults2.Runout1 AS RO
FROM tblResults2].
GROUP BY PlayerName, Team;
Note the square brackets and the closing period around the subquery.
--
John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/http://social...
and see alsohttp://
www.utteraccess.com-Hidequotedtext -
- Show quoted text -
That one works. Thanks.
How about creating a table from a union query. Is that possible?
Also, i have been on the forms board because I am trying to update my
table with all the data at once. Right now I do it single form one
line at a time. And I can do it continuos form all 21 lines. But
here's the rub. On my single form i have combo boxes for the players
that are populated when i enter the match. In other words, I enter say
Team A verus Team B and each combo box than shows a drop down list of
player. That way i can't misspell anyone's name. Problem is on a
continuous form, all the names change every time i change then name..
Is there a way to stop that?- Hide quoted text -
- Show quoted text -
Thanks. Is there a way to create a table from a Union Query?- Hide quoted text -
The reason i make a table is twofold. first is as the season
progresses, there are queries that take longer to run. So i make them
make-table queries and then run my reports from the table. that way
only when i make the table does it take a long time. otherwise i takes
a long time for every report.
The second reason is that when i transfer to mySQL eventually, it will
be easier sice mySQL only runs queries off of tables. so i need to
create table and the run output queries after. but taht will be a
while since the sql is different.
Anyway thanks for your help but i need another answer if you don't
mind
Currently i have a query like this
SELECT myData.PlayerID, Count(qlatestLost.PlayerID) AS
currentWinStreak
FROM myData LEFT JOIN qlatestLost ON myData.playerID =
qlatestLost.playerID
GROUP BY myData.PlayerID;
What i want to do is replace myData and qlatestLost with their actual
queries. basically the from statement myData is replaced by
SELECT myData.PlayerID, Max(IIf(isWin,-1,1)*GameID) AS Mgame
FROM (SELECT GameID, Winner As PlayerID, true AS isWin
FROM (SELECT tblStats_All.GameID, tblStats_All.GameDate,
tblStats_All.HomeTeam, tblStats_All.PlayerName AS Winner,
tblStats_All.Team, tblStats_All.Opponent AS Loser,
tblStats_All.Op_Team, tblStats_All.Won
FROM tblStats_All
WHERE (((tblStats_All.Won)=1)))
UNION ALL SELECT GameID, Loser, false
FROM (SELECT tblStats_All.GameID, tblStats_All.GameDate,
tblStats_All.HomeTeam, tblStats_All.PlayerName AS Winner,
tblStats_All.Team, tblStats_All.Opponent AS Loser,
tblStats_All.Op_Team, tblStats_All.Won
FROM tblStats_All
WHERE (((tblStats_All.Won)=1)))) AS myData
GROUP BY myData.PlayerID;
and then the join qlatest lost is replaced by
SELECT GameID, Winner As PlayerID, true AS isWin
FROM (SELECT tblStats_All.GameID, tblStats_All.GameDate,
tblStats_All.HomeTeam, tblStats_All.PlayerName AS Winner,
tblStats_All.Team, tblStats_All.Opponent AS Loser,
tblStats_All.Op_Team, tblStats_All.Won
FROM tblStats_All
WHERE (((tblStats_All.Won)=1)))
UNION ALL SELECT GameID, Loser, false
FROM (SELECT tblStats_All.GameID, tblStats_All.GameDate,
tblStats_All.HomeTeam, tblStats_All.PlayerName AS Winner,
tblStats_All.Team, tblStats_All.Opponent AS Loser,
tblStats_All.Op_Team, tblStats_All.Won
FROM tblStats_All
WHERE (((tblStats_All.Won)=1)));
So this is what i have but it is not working.
SELECT myData.PlayerID, Count(qlatestLost.PlayerID) AS
currentWinStreak
FROM (SELECT myData.PlayerID, Max(IIf(isWin,-1,1)*GameID) AS Mgame
FROM (SELECT GameID, Winner As PlayerID, true AS isWin
FROM (SELECT tblStats_All.GameID, tblStats_All.GameDate,
tblStats_All.HomeTeam, tblStats_All.PlayerName AS Winner,
tblStats_All.Team, tblStats_All.Opponent AS Loser,
tblStats_All.Op_Team, tblStats_All.Won
FROM tblStats_All
WHERE (((tblStats_All.Won)=1)))
UNION ALL SELECT GameID, Loser, false
FROM (SELECT tblStats_All.GameID, tblStats_All.GameDate,
tblStats_All.HomeTeam, tblStats_All.PlayerName AS Winner,
tblStats_All.Team, tblStats_All.Opponent AS Loser,
tblStats_All.Op_Team, tblStats_All.Won
FROM tblStats_All
WHERE (((tblStats_All.Won)=1)))) AS myData) LEFT JOIN (SELECT GameID,
Winner As PlayerID, true AS isWin
FROM (SELECT tblStats_All.GameID, tblStats_All.GameDate,
tblStats_All.HomeTeam, tblStats_All.PlayerName AS Winner,
tblStats_All.Team, tblStats_All.Opponent AS Loser,
tblStats_All.Op_Team, tblStats_All.Won
FROM tblStats_All
WHERE (((tblStats_All.Won)=1)))
UNION ALL SELECT GameID, Loser, false
FROM (SELECT tblStats_All.GameID, tblStats_All.GameDate,
tblStats_All.HomeTeam, tblStats_All.PlayerName AS Winner,
tblStats_All.Team, tblStats_All.Opponent AS Loser,
tblStats_All.Op_Team, tblStats_All.Won
FROM tblStats_All
WHERE (((tblStats_All.Won)=1)))) AS qlatestLost ON myData.playerID =
qlatestLost.playerID
GROUP BY myData.PlayerID;
I get syntax error in join operation. can you help?- Hide quoted text -
- Show quoted text -