Mysql count id that appear in 2 columns
I have a table with these columns:
- id
- user_id
- player_in
- player_out
- date
I need to make a report that count the number of repetitions each "player" both in player_in field, as in player_out field.
For example, if I have this 2 rows in the table (in the respective order).
id user_id player_in player_out
1 1 88 56
2 7 77 88
The result for the player 88 will be 2, and for the players 56 and 77, just 1
mysql sql count
add a comment |
I have a table with these columns:
- id
- user_id
- player_in
- player_out
- date
I need to make a report that count the number of repetitions each "player" both in player_in field, as in player_out field.
For example, if I have this 2 rows in the table (in the respective order).
id user_id player_in player_out
1 1 88 56
2 7 77 88
The result for the player 88 will be 2, and for the players 56 and 77, just 1
mysql sql count
+1 I would like to know that too.
– ncm
Jul 7 '13 at 14:47
1
WouldSELECT COUNT(player_in), (SELECT COUNT(player_out) FROM myTable GROUP BY player_out) AS player_out FROM myTable GROUP BY player_in
work?
– David Starkey
Jul 7 '13 at 14:47
+1. nice way.I think you are so smart.
– ncm
Jul 7 '13 at 14:49
MySQL throw this error: #1242 - Subquery returns more than 1 row. Why?
– mauriblint
Jul 7 '13 at 14:54
add a comment |
I have a table with these columns:
- id
- user_id
- player_in
- player_out
- date
I need to make a report that count the number of repetitions each "player" both in player_in field, as in player_out field.
For example, if I have this 2 rows in the table (in the respective order).
id user_id player_in player_out
1 1 88 56
2 7 77 88
The result for the player 88 will be 2, and for the players 56 and 77, just 1
mysql sql count
I have a table with these columns:
- id
- user_id
- player_in
- player_out
- date
I need to make a report that count the number of repetitions each "player" both in player_in field, as in player_out field.
For example, if I have this 2 rows in the table (in the respective order).
id user_id player_in player_out
1 1 88 56
2 7 77 88
The result for the player 88 will be 2, and for the players 56 and 77, just 1
mysql sql count
mysql sql count
edited Nov 13 '18 at 5:52
Cœur
19k9112154
19k9112154
asked Jul 7 '13 at 14:43
mauriblintmauriblint
74521233
74521233
+1 I would like to know that too.
– ncm
Jul 7 '13 at 14:47
1
WouldSELECT COUNT(player_in), (SELECT COUNT(player_out) FROM myTable GROUP BY player_out) AS player_out FROM myTable GROUP BY player_in
work?
– David Starkey
Jul 7 '13 at 14:47
+1. nice way.I think you are so smart.
– ncm
Jul 7 '13 at 14:49
MySQL throw this error: #1242 - Subquery returns more than 1 row. Why?
– mauriblint
Jul 7 '13 at 14:54
add a comment |
+1 I would like to know that too.
– ncm
Jul 7 '13 at 14:47
1
WouldSELECT COUNT(player_in), (SELECT COUNT(player_out) FROM myTable GROUP BY player_out) AS player_out FROM myTable GROUP BY player_in
work?
– David Starkey
Jul 7 '13 at 14:47
+1. nice way.I think you are so smart.
– ncm
Jul 7 '13 at 14:49
MySQL throw this error: #1242 - Subquery returns more than 1 row. Why?
– mauriblint
Jul 7 '13 at 14:54
+1 I would like to know that too.
– ncm
Jul 7 '13 at 14:47
+1 I would like to know that too.
– ncm
Jul 7 '13 at 14:47
1
1
Would
SELECT COUNT(player_in), (SELECT COUNT(player_out) FROM myTable GROUP BY player_out) AS player_out FROM myTable GROUP BY player_in
work?– David Starkey
Jul 7 '13 at 14:47
Would
SELECT COUNT(player_in), (SELECT COUNT(player_out) FROM myTable GROUP BY player_out) AS player_out FROM myTable GROUP BY player_in
work?– David Starkey
Jul 7 '13 at 14:47
+1. nice way.I think you are so smart.
– ncm
Jul 7 '13 at 14:49
+1. nice way.I think you are so smart.
– ncm
Jul 7 '13 at 14:49
MySQL throw this error: #1242 - Subquery returns more than 1 row. Why?
– mauriblint
Jul 7 '13 at 14:54
MySQL throw this error: #1242 - Subquery returns more than 1 row. Why?
– mauriblint
Jul 7 '13 at 14:54
add a comment |
2 Answers
2
active
oldest
votes
Use a subquery that employs union all
to get the two column into one column, then use a standard count(*)
:
Note: Thus query included individual totals for ins and outs as per further request in comments to this answer.
select
player_id,
count(*) as total,
sum(ins) as ins,
sum(outs) as outs
from (
select
player_in as player_id,
1 as ins,
0 as outs
from mytable
union all
select player_out, 0, 1
from mytable
) x
group by player_id
Note: you must use union all
(not just union
), because union
removes duplicates whereas union all
does not.
This works fine i think, I have a table with multiple rows and I cant count one by one to check this, but i think this work fine. Is there any way to optimize the query?
– mauriblint
Jul 7 '13 at 14:57
You could put separate indexes on player_in and player_out. Other than that, the query's about as simple as it gets - should perform fine.
– Bohemian♦
Jul 7 '13 at 15:04
Ok! one more question, how can i get the 3 items, "ins" "outs" and "total" for each player? Thanks a lot.
– mauriblint
Jul 7 '13 at 15:45
That's actually a different question, but see answer for bonus edits to see how.
– Bohemian♦
Jul 7 '13 at 20:39
1
Added comma. (I typed this in on my iPhone... It can be harder to spot mistakes like that)
– Bohemian♦
Jul 7 '13 at 23:08
|
show 3 more comments
You could use a cross-join to a 2-row virtual table to unpivot the player_*
columns, then group the results, like this:
SELECT
player,
COUNT(*) AS total_count
FROM (
SELECT
CASE WHEN x.is_in THEN t.player_in ELSE t.player_out END AS player
FROM mytable t
CROSS JOIN (SELECT TRUE AS is_in UNION ALL SELECT FALSE) x
) s
GROUP BY
player
;
That is, every row of the original table is essentially duplicated and each copy of the row supplies either player_in
or player_out
, depending on whether the derived table's is_in
column is TRUE
or FALSE
, to form a single player
column. This method of unpivoting might perform better than the UNION method suggested by @Bohemian because this way the (physical) table is passed just once (but you'd need to test and compare both methods to determine if there's any substantial benefit to this approach in your particular situation).
To calculate in and out counts, as you have requested in one of your comments to the above mentioned answer, you could extend my original suggestion like this:
SELECT
player,
COUNT( is_in OR NULL) AS in_count,
COUNT(NOT is_in OR NULL) AS out_count,
COUNT(*) AS total_count
FROM (
SELECT
x.is_in,
CASE WHEN x.is_in THEN t.player_in ELSE t.player_out END AS player
FROM mytable t
CROSS JOIN (SELECT TRUE AS is_in UNION ALL SELECT FALSE) x
) s
GROUP BY
player
;
As you can see, the derived table now additionally returns the is_in
column in its own right, and the column is used in two conditional aggregations for counting how many times a player was in and out. (If you are interested, the OR NULL
trick is explained here.)
You could also rewrite the COUNT(condition OR NULL)
entries as SUM(condition)
. That would certainly shorten both expressions, some also find the SUM
method of counting clearer/more elegant. In either event, there would likely be no difference in performance, so choose whichever method suits your taste better.
A SQL Fiddle demo of the second query can be found here.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f17513129%2fmysql-count-id-that-appear-in-2-columns%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Use a subquery that employs union all
to get the two column into one column, then use a standard count(*)
:
Note: Thus query included individual totals for ins and outs as per further request in comments to this answer.
select
player_id,
count(*) as total,
sum(ins) as ins,
sum(outs) as outs
from (
select
player_in as player_id,
1 as ins,
0 as outs
from mytable
union all
select player_out, 0, 1
from mytable
) x
group by player_id
Note: you must use union all
(not just union
), because union
removes duplicates whereas union all
does not.
This works fine i think, I have a table with multiple rows and I cant count one by one to check this, but i think this work fine. Is there any way to optimize the query?
– mauriblint
Jul 7 '13 at 14:57
You could put separate indexes on player_in and player_out. Other than that, the query's about as simple as it gets - should perform fine.
– Bohemian♦
Jul 7 '13 at 15:04
Ok! one more question, how can i get the 3 items, "ins" "outs" and "total" for each player? Thanks a lot.
– mauriblint
Jul 7 '13 at 15:45
That's actually a different question, but see answer for bonus edits to see how.
– Bohemian♦
Jul 7 '13 at 20:39
1
Added comma. (I typed this in on my iPhone... It can be harder to spot mistakes like that)
– Bohemian♦
Jul 7 '13 at 23:08
|
show 3 more comments
Use a subquery that employs union all
to get the two column into one column, then use a standard count(*)
:
Note: Thus query included individual totals for ins and outs as per further request in comments to this answer.
select
player_id,
count(*) as total,
sum(ins) as ins,
sum(outs) as outs
from (
select
player_in as player_id,
1 as ins,
0 as outs
from mytable
union all
select player_out, 0, 1
from mytable
) x
group by player_id
Note: you must use union all
(not just union
), because union
removes duplicates whereas union all
does not.
This works fine i think, I have a table with multiple rows and I cant count one by one to check this, but i think this work fine. Is there any way to optimize the query?
– mauriblint
Jul 7 '13 at 14:57
You could put separate indexes on player_in and player_out. Other than that, the query's about as simple as it gets - should perform fine.
– Bohemian♦
Jul 7 '13 at 15:04
Ok! one more question, how can i get the 3 items, "ins" "outs" and "total" for each player? Thanks a lot.
– mauriblint
Jul 7 '13 at 15:45
That's actually a different question, but see answer for bonus edits to see how.
– Bohemian♦
Jul 7 '13 at 20:39
1
Added comma. (I typed this in on my iPhone... It can be harder to spot mistakes like that)
– Bohemian♦
Jul 7 '13 at 23:08
|
show 3 more comments
Use a subquery that employs union all
to get the two column into one column, then use a standard count(*)
:
Note: Thus query included individual totals for ins and outs as per further request in comments to this answer.
select
player_id,
count(*) as total,
sum(ins) as ins,
sum(outs) as outs
from (
select
player_in as player_id,
1 as ins,
0 as outs
from mytable
union all
select player_out, 0, 1
from mytable
) x
group by player_id
Note: you must use union all
(not just union
), because union
removes duplicates whereas union all
does not.
Use a subquery that employs union all
to get the two column into one column, then use a standard count(*)
:
Note: Thus query included individual totals for ins and outs as per further request in comments to this answer.
select
player_id,
count(*) as total,
sum(ins) as ins,
sum(outs) as outs
from (
select
player_in as player_id,
1 as ins,
0 as outs
from mytable
union all
select player_out, 0, 1
from mytable
) x
group by player_id
Note: you must use union all
(not just union
), because union
removes duplicates whereas union all
does not.
edited Jul 7 '13 at 23:07
answered Jul 7 '13 at 14:48
Bohemian♦Bohemian
299k65428566
299k65428566
This works fine i think, I have a table with multiple rows and I cant count one by one to check this, but i think this work fine. Is there any way to optimize the query?
– mauriblint
Jul 7 '13 at 14:57
You could put separate indexes on player_in and player_out. Other than that, the query's about as simple as it gets - should perform fine.
– Bohemian♦
Jul 7 '13 at 15:04
Ok! one more question, how can i get the 3 items, "ins" "outs" and "total" for each player? Thanks a lot.
– mauriblint
Jul 7 '13 at 15:45
That's actually a different question, but see answer for bonus edits to see how.
– Bohemian♦
Jul 7 '13 at 20:39
1
Added comma. (I typed this in on my iPhone... It can be harder to spot mistakes like that)
– Bohemian♦
Jul 7 '13 at 23:08
|
show 3 more comments
This works fine i think, I have a table with multiple rows and I cant count one by one to check this, but i think this work fine. Is there any way to optimize the query?
– mauriblint
Jul 7 '13 at 14:57
You could put separate indexes on player_in and player_out. Other than that, the query's about as simple as it gets - should perform fine.
– Bohemian♦
Jul 7 '13 at 15:04
Ok! one more question, how can i get the 3 items, "ins" "outs" and "total" for each player? Thanks a lot.
– mauriblint
Jul 7 '13 at 15:45
That's actually a different question, but see answer for bonus edits to see how.
– Bohemian♦
Jul 7 '13 at 20:39
1
Added comma. (I typed this in on my iPhone... It can be harder to spot mistakes like that)
– Bohemian♦
Jul 7 '13 at 23:08
This works fine i think, I have a table with multiple rows and I cant count one by one to check this, but i think this work fine. Is there any way to optimize the query?
– mauriblint
Jul 7 '13 at 14:57
This works fine i think, I have a table with multiple rows and I cant count one by one to check this, but i think this work fine. Is there any way to optimize the query?
– mauriblint
Jul 7 '13 at 14:57
You could put separate indexes on player_in and player_out. Other than that, the query's about as simple as it gets - should perform fine.
– Bohemian♦
Jul 7 '13 at 15:04
You could put separate indexes on player_in and player_out. Other than that, the query's about as simple as it gets - should perform fine.
– Bohemian♦
Jul 7 '13 at 15:04
Ok! one more question, how can i get the 3 items, "ins" "outs" and "total" for each player? Thanks a lot.
– mauriblint
Jul 7 '13 at 15:45
Ok! one more question, how can i get the 3 items, "ins" "outs" and "total" for each player? Thanks a lot.
– mauriblint
Jul 7 '13 at 15:45
That's actually a different question, but see answer for bonus edits to see how.
– Bohemian♦
Jul 7 '13 at 20:39
That's actually a different question, but see answer for bonus edits to see how.
– Bohemian♦
Jul 7 '13 at 20:39
1
1
Added comma. (I typed this in on my iPhone... It can be harder to spot mistakes like that)
– Bohemian♦
Jul 7 '13 at 23:08
Added comma. (I typed this in on my iPhone... It can be harder to spot mistakes like that)
– Bohemian♦
Jul 7 '13 at 23:08
|
show 3 more comments
You could use a cross-join to a 2-row virtual table to unpivot the player_*
columns, then group the results, like this:
SELECT
player,
COUNT(*) AS total_count
FROM (
SELECT
CASE WHEN x.is_in THEN t.player_in ELSE t.player_out END AS player
FROM mytable t
CROSS JOIN (SELECT TRUE AS is_in UNION ALL SELECT FALSE) x
) s
GROUP BY
player
;
That is, every row of the original table is essentially duplicated and each copy of the row supplies either player_in
or player_out
, depending on whether the derived table's is_in
column is TRUE
or FALSE
, to form a single player
column. This method of unpivoting might perform better than the UNION method suggested by @Bohemian because this way the (physical) table is passed just once (but you'd need to test and compare both methods to determine if there's any substantial benefit to this approach in your particular situation).
To calculate in and out counts, as you have requested in one of your comments to the above mentioned answer, you could extend my original suggestion like this:
SELECT
player,
COUNT( is_in OR NULL) AS in_count,
COUNT(NOT is_in OR NULL) AS out_count,
COUNT(*) AS total_count
FROM (
SELECT
x.is_in,
CASE WHEN x.is_in THEN t.player_in ELSE t.player_out END AS player
FROM mytable t
CROSS JOIN (SELECT TRUE AS is_in UNION ALL SELECT FALSE) x
) s
GROUP BY
player
;
As you can see, the derived table now additionally returns the is_in
column in its own right, and the column is used in two conditional aggregations for counting how many times a player was in and out. (If you are interested, the OR NULL
trick is explained here.)
You could also rewrite the COUNT(condition OR NULL)
entries as SUM(condition)
. That would certainly shorten both expressions, some also find the SUM
method of counting clearer/more elegant. In either event, there would likely be no difference in performance, so choose whichever method suits your taste better.
A SQL Fiddle demo of the second query can be found here.
add a comment |
You could use a cross-join to a 2-row virtual table to unpivot the player_*
columns, then group the results, like this:
SELECT
player,
COUNT(*) AS total_count
FROM (
SELECT
CASE WHEN x.is_in THEN t.player_in ELSE t.player_out END AS player
FROM mytable t
CROSS JOIN (SELECT TRUE AS is_in UNION ALL SELECT FALSE) x
) s
GROUP BY
player
;
That is, every row of the original table is essentially duplicated and each copy of the row supplies either player_in
or player_out
, depending on whether the derived table's is_in
column is TRUE
or FALSE
, to form a single player
column. This method of unpivoting might perform better than the UNION method suggested by @Bohemian because this way the (physical) table is passed just once (but you'd need to test and compare both methods to determine if there's any substantial benefit to this approach in your particular situation).
To calculate in and out counts, as you have requested in one of your comments to the above mentioned answer, you could extend my original suggestion like this:
SELECT
player,
COUNT( is_in OR NULL) AS in_count,
COUNT(NOT is_in OR NULL) AS out_count,
COUNT(*) AS total_count
FROM (
SELECT
x.is_in,
CASE WHEN x.is_in THEN t.player_in ELSE t.player_out END AS player
FROM mytable t
CROSS JOIN (SELECT TRUE AS is_in UNION ALL SELECT FALSE) x
) s
GROUP BY
player
;
As you can see, the derived table now additionally returns the is_in
column in its own right, and the column is used in two conditional aggregations for counting how many times a player was in and out. (If you are interested, the OR NULL
trick is explained here.)
You could also rewrite the COUNT(condition OR NULL)
entries as SUM(condition)
. That would certainly shorten both expressions, some also find the SUM
method of counting clearer/more elegant. In either event, there would likely be no difference in performance, so choose whichever method suits your taste better.
A SQL Fiddle demo of the second query can be found here.
add a comment |
You could use a cross-join to a 2-row virtual table to unpivot the player_*
columns, then group the results, like this:
SELECT
player,
COUNT(*) AS total_count
FROM (
SELECT
CASE WHEN x.is_in THEN t.player_in ELSE t.player_out END AS player
FROM mytable t
CROSS JOIN (SELECT TRUE AS is_in UNION ALL SELECT FALSE) x
) s
GROUP BY
player
;
That is, every row of the original table is essentially duplicated and each copy of the row supplies either player_in
or player_out
, depending on whether the derived table's is_in
column is TRUE
or FALSE
, to form a single player
column. This method of unpivoting might perform better than the UNION method suggested by @Bohemian because this way the (physical) table is passed just once (but you'd need to test and compare both methods to determine if there's any substantial benefit to this approach in your particular situation).
To calculate in and out counts, as you have requested in one of your comments to the above mentioned answer, you could extend my original suggestion like this:
SELECT
player,
COUNT( is_in OR NULL) AS in_count,
COUNT(NOT is_in OR NULL) AS out_count,
COUNT(*) AS total_count
FROM (
SELECT
x.is_in,
CASE WHEN x.is_in THEN t.player_in ELSE t.player_out END AS player
FROM mytable t
CROSS JOIN (SELECT TRUE AS is_in UNION ALL SELECT FALSE) x
) s
GROUP BY
player
;
As you can see, the derived table now additionally returns the is_in
column in its own right, and the column is used in two conditional aggregations for counting how many times a player was in and out. (If you are interested, the OR NULL
trick is explained here.)
You could also rewrite the COUNT(condition OR NULL)
entries as SUM(condition)
. That would certainly shorten both expressions, some also find the SUM
method of counting clearer/more elegant. In either event, there would likely be no difference in performance, so choose whichever method suits your taste better.
A SQL Fiddle demo of the second query can be found here.
You could use a cross-join to a 2-row virtual table to unpivot the player_*
columns, then group the results, like this:
SELECT
player,
COUNT(*) AS total_count
FROM (
SELECT
CASE WHEN x.is_in THEN t.player_in ELSE t.player_out END AS player
FROM mytable t
CROSS JOIN (SELECT TRUE AS is_in UNION ALL SELECT FALSE) x
) s
GROUP BY
player
;
That is, every row of the original table is essentially duplicated and each copy of the row supplies either player_in
or player_out
, depending on whether the derived table's is_in
column is TRUE
or FALSE
, to form a single player
column. This method of unpivoting might perform better than the UNION method suggested by @Bohemian because this way the (physical) table is passed just once (but you'd need to test and compare both methods to determine if there's any substantial benefit to this approach in your particular situation).
To calculate in and out counts, as you have requested in one of your comments to the above mentioned answer, you could extend my original suggestion like this:
SELECT
player,
COUNT( is_in OR NULL) AS in_count,
COUNT(NOT is_in OR NULL) AS out_count,
COUNT(*) AS total_count
FROM (
SELECT
x.is_in,
CASE WHEN x.is_in THEN t.player_in ELSE t.player_out END AS player
FROM mytable t
CROSS JOIN (SELECT TRUE AS is_in UNION ALL SELECT FALSE) x
) s
GROUP BY
player
;
As you can see, the derived table now additionally returns the is_in
column in its own right, and the column is used in two conditional aggregations for counting how many times a player was in and out. (If you are interested, the OR NULL
trick is explained here.)
You could also rewrite the COUNT(condition OR NULL)
entries as SUM(condition)
. That would certainly shorten both expressions, some also find the SUM
method of counting clearer/more elegant. In either event, there would likely be no difference in performance, so choose whichever method suits your taste better.
A SQL Fiddle demo of the second query can be found here.
edited May 23 '17 at 12:11
Community♦
11
11
answered Jul 10 '13 at 0:21
Andriy MAndriy M
63.7k1379132
63.7k1379132
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f17513129%2fmysql-count-id-that-appear-in-2-columns%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
+1 I would like to know that too.
– ncm
Jul 7 '13 at 14:47
1
Would
SELECT COUNT(player_in), (SELECT COUNT(player_out) FROM myTable GROUP BY player_out) AS player_out FROM myTable GROUP BY player_in
work?– David Starkey
Jul 7 '13 at 14:47
+1. nice way.I think you are so smart.
– ncm
Jul 7 '13 at 14:49
MySQL throw this error: #1242 - Subquery returns more than 1 row. Why?
– mauriblint
Jul 7 '13 at 14:54