Skip to main content
added 83 characters in body
Source Link
Chava Geldzahler
  • 3.8k
  • 1
  • 20
  • 32

As in (using your example):

"SELECT sum1, sum2 FROM (SELECT kp.pts + kp2.pts2 + kp3.pts3 + kp4.pts4 + kp5.pts5 + kp6.pts6 + kp7.pts7 + kp8.pts8 + kp9.pts9 AS sum1 FROM knightsplayer AS kp JOIN knightsplayer2 AS kp2 ON kp.id = kp2.id2 JOIN knightsplayer3 AS kp3 ON kp.id = kp3.id3 JOIN knightsplayer4 AS kp4 ON kp.id = kp4.id4 JOIN knightsplayer5 AS kp5 ON kp.id = kp5.id5 JOIN knightsplayer6 AS kp6 ON kp.id = kp6.id6 JOIN knightsplayer7 AS kp7 ON kp.id = kp7.id7 JOIN knightsplayer8 AS kp8 ON kp.id = kp8.id8 JOIN knightsplayer9 AS kp9 ON kp.id = kp9.id9) as table1, (SELECT bp.pts + bp2.pts2 + bp3.pts3 + bp4.pts4 + bp5.pts5 + bp6.pts6 + bp7.pts7 + bp8.pts8 + bp9.pts9 AS sum2 FROM blazersplayer AS bp JOIN blazersplayer2 AS bp2 ON bp.id = bp2.id2 JOIN blazersplayer3 AS bp3 ON bp.id = bp3.id3 JOIN blazersplayer4 AS bp4 ON bp.id = bp4.id4 JOIN blazersplayer5 AS bp5 ON bp.id = bp5.id5 JOIN blazersplayer6 AS bp6 ON bp.id = bp6.id6 JOIN blazersplayer7 AS bp7 ON bp.id = bp7.id7 JOIN blazersplayer8 AS bp8 ON bp.id = bp8.id8 JOIN blazersplayer9 AS bp9 ON bp.id = bp9.id9) as table2;" 

Or, if you need to join the two inline views:

Or, if you need to join the two inline views:

As in (using your example):

"SELECT sum1, sum2 FROM (SELECT kp.pts + kp2.pts2 + kp3.pts3 + kp4.pts4 + kp5.pts5 + kp6.pts6 + kp7.pts7 + kp8.pts8 + kp9.pts9 AS sum1 FROM knightsplayer AS kp JOIN knightsplayer2 AS kp2 ON kp.id = kp2.id2 JOIN knightsplayer3 AS kp3 ON kp.id = kp3.id3 JOIN knightsplayer4 AS kp4 ON kp.id = kp4.id4 JOIN knightsplayer5 AS kp5 ON kp.id = kp5.id5 JOIN knightsplayer6 AS kp6 ON kp.id = kp6.id6 JOIN knightsplayer7 AS kp7 ON kp.id = kp7.id7 JOIN knightsplayer8 AS kp8 ON kp.id = kp8.id8 JOIN knightsplayer9 AS kp9 ON kp.id = kp9.id9) as table1, (SELECT bp.pts + bp2.pts2 + bp3.pts3 + bp4.pts4 + bp5.pts5 + bp6.pts6 + bp7.pts7 + bp8.pts8 + bp9.pts9 AS sum2 FROM blazersplayer AS bp JOIN blazersplayer2 AS bp2 ON bp.id = bp2.id2 JOIN blazersplayer3 AS bp3 ON bp.id = bp3.id3 JOIN blazersplayer4 AS bp4 ON bp.id = bp4.id4 JOIN blazersplayer5 AS bp5 ON bp.id = bp5.id5 JOIN blazersplayer6 AS bp6 ON bp.id = bp6.id6 JOIN blazersplayer7 AS bp7 ON bp.id = bp7.id7 JOIN blazersplayer8 AS bp8 ON bp.id = bp8.id8 JOIN blazersplayer9 AS bp9 ON bp.id = bp9.id9) as table2;" 

Or, if you need to join the two inline views:

added 83 characters in body
Source Link
Chava Geldzahler
  • 3.8k
  • 1
  • 20
  • 32

You have a subquery in your SELECT clause, but you don't have a FROM clause to complete the outer query.

Also, the ; between the two subqueries, denotes the end of the SQL statement.

You can do something like:

SELECT sum1, sum2 FROM (subquery1 here) as table1, (subquery2 here) as table2; 

Or, if you need to join the two inline views:

SELECT sum1, sum2 FROM (subquery1 here) as table1 JOIN (subquery2 here) as table2 ON (join condition); 

Keep in mind that if you do need to join the two inline views, you need to select a column (aside from sum1/sum2) to join on.

You have a subquery in your SELECT clause, but you don't have a FROM clause to complete the outer query.

Also, the ; between the two subqueries, denotes the end of the SQL statement.

You can do something like:

SELECT sum1, sum2 FROM (subquery1 here) as table1, (subquery2 here) as table2; 

Or, if you need to join the two inline views:

SELECT sum1, sum2 FROM (subquery1 here) as table1 JOIN (subquery2 here) as table2 ON (join condition); 

You have a subquery in your SELECT clause, but you don't have a FROM clause to complete the outer query.

Also, the ; between the two subqueries, denotes the end of the SQL statement.

You can do something like:

SELECT sum1, sum2 FROM (subquery1 here) as table1, (subquery2 here) as table2; 

Or, if you need to join the two inline views:

SELECT sum1, sum2 FROM (subquery1 here) as table1 JOIN (subquery2 here) as table2 ON (join condition); 

Keep in mind that if you do need to join the two inline views, you need to select a column (aside from sum1/sum2) to join on.

added 83 characters in body
Source Link
Chava Geldzahler
  • 3.8k
  • 1
  • 20
  • 32

You have a subquery in your SELECT clause, but you don't have a FROM clause to complete the outer query.

Also, the ; between the two subqueries, denotes the end of the SQL statement.

You can do something like:

SELECT sum1, sum2 FROM (subquery1 here) as table1, (subquery2 here) as table2; 

Or, if you need to join the two inline views:

SELECT sum1, sum2 FROM (subquery1 here) as table1 JOIN (subquery2 here) as table2 ON (join condition); 

You have a subquery in your SELECT clause, but you don't have a FROM clause to complete the outer query.

You can do something like:

SELECT sum1, sum2 FROM (subquery1 here) as table1 JOIN (subquery2 here) as table2 ON (join condition); 

You have a subquery in your SELECT clause, but you don't have a FROM clause to complete the outer query.

Also, the ; between the two subqueries, denotes the end of the SQL statement.

You can do something like:

SELECT sum1, sum2 FROM (subquery1 here) as table1, (subquery2 here) as table2; 

Or, if you need to join the two inline views:

SELECT sum1, sum2 FROM (subquery1 here) as table1 JOIN (subquery2 here) as table2 ON (join condition); 
Source Link
Chava Geldzahler
  • 3.8k
  • 1
  • 20
  • 32
Loading