SELECT statement inner joinINNER JOIN ON vs WHERE clauseMySQL: selecting rows where a column is nullWhat's the difference between INNER JOIN, LEFT JOIN, RIGHT JOIN and FULL JOIN?MySQL INNER JOIN of 3 tables with count and totalsINNER JOIN select columns from table2MYSQL inner join with a count sub queryConditional inner join statements in MySQLSelect MIN value on INNER JOINhow to use group by with inner joinmagento join entity id with product sku from query result

Is it possible for underground bunkers on different continents to be connected?

How to know whether to write accidentals as sharps or flats?

Does knowing the surface area of all faces uniquely determine a tetrahedron?

How do credit card companies know what type of business I'm paying for?

Why do you need to heat the pan before heating the olive oil?

My student in one course asks for paid tutoring in another course. Appropriate?

What is the precise meaning of "подсел на мак"?

Testing thermite for chemical properties

The instant an accelerating object has zero speed, is it speeding up, slowing down, or neither?

Is swap gate equivalent to just exchanging the wire of the two qubits?

Someone who is granted access to information but not expected to read it

I have found ports on my Samsung smart tv running a display service. What can I do with it?

Is it a bad idea to have a pen name with only an initial for a surname?

How can Caller ID be faked?

Interview was just a one hour panel. Got an offer the next day; do I accept or is this a red flag?

Redirecting output only on a successful command call

Class to generate a pdf invoice

How to make all magic-casting innate, but still rare?

Leaving job close to major deadlines

High-end PC graphics circa 1990?

What could be the physiological mechanism for a biological Geiger counter?

Why should the equality of mixed partials be "intuitively obvious"?

How Linux command "mount -a" works

How useful is the GRE Exam?



SELECT statement inner join


INNER JOIN ON vs WHERE clauseMySQL: selecting rows where a column is nullWhat's the difference between INNER JOIN, LEFT JOIN, RIGHT JOIN and FULL JOIN?MySQL INNER JOIN of 3 tables with count and totalsINNER JOIN select columns from table2MYSQL inner join with a count sub queryConditional inner join statements in MySQLSelect MIN value on INNER JOINhow to use group by with inner joinmagento join entity id with product sku from query result






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-1















I'm trying to find out if I can make one query to out of three I have now.



 $sql = "SELECT * 
FROM joblist WHERE customer = :customer"; // this is a bindParam

$sql_val = "SELECT a.customer, SUM(a.value) AS tvalue
FROM joblist AS a
INNER JOIN joblist AS b
ON a.customer = b.customer
GROUP BY a.customer";

$sql_bal = "SELECT *
FROM (SELECT SUM(balance) AS tbalance
FROM joblist GROUP BY customer) AS total_balance
WHERE tbalance = :tbalance";


The table that I am using is customer and following is are the columns.



ID - work_order - customer - description - value - balance - status - notes


I'm using php PDO and HTMl of course.



Basically, I have a search function used to query a company. The result are displayed, but I need the totals for the value and balance columns. The only thing that really works is pulling in the data from the table. I've had no success at getting the totals for value and balance.



Current code page










share|improve this question
























  • Explain exactly what you're expecting by joining the queries and the issue you're getting by combining three queries.

    – Harshana
    Mar 25 at 4:22











  • i can't understand your question.please make it clear

    – Tom
    Mar 25 at 5:52

















-1















I'm trying to find out if I can make one query to out of three I have now.



 $sql = "SELECT * 
FROM joblist WHERE customer = :customer"; // this is a bindParam

$sql_val = "SELECT a.customer, SUM(a.value) AS tvalue
FROM joblist AS a
INNER JOIN joblist AS b
ON a.customer = b.customer
GROUP BY a.customer";

$sql_bal = "SELECT *
FROM (SELECT SUM(balance) AS tbalance
FROM joblist GROUP BY customer) AS total_balance
WHERE tbalance = :tbalance";


The table that I am using is customer and following is are the columns.



ID - work_order - customer - description - value - balance - status - notes


I'm using php PDO and HTMl of course.



Basically, I have a search function used to query a company. The result are displayed, but I need the totals for the value and balance columns. The only thing that really works is pulling in the data from the table. I've had no success at getting the totals for value and balance.



Current code page










share|improve this question
























  • Explain exactly what you're expecting by joining the queries and the issue you're getting by combining three queries.

    – Harshana
    Mar 25 at 4:22











  • i can't understand your question.please make it clear

    – Tom
    Mar 25 at 5:52













-1












-1








-1








I'm trying to find out if I can make one query to out of three I have now.



 $sql = "SELECT * 
FROM joblist WHERE customer = :customer"; // this is a bindParam

$sql_val = "SELECT a.customer, SUM(a.value) AS tvalue
FROM joblist AS a
INNER JOIN joblist AS b
ON a.customer = b.customer
GROUP BY a.customer";

$sql_bal = "SELECT *
FROM (SELECT SUM(balance) AS tbalance
FROM joblist GROUP BY customer) AS total_balance
WHERE tbalance = :tbalance";


The table that I am using is customer and following is are the columns.



ID - work_order - customer - description - value - balance - status - notes


I'm using php PDO and HTMl of course.



Basically, I have a search function used to query a company. The result are displayed, but I need the totals for the value and balance columns. The only thing that really works is pulling in the data from the table. I've had no success at getting the totals for value and balance.



Current code page










share|improve this question
















I'm trying to find out if I can make one query to out of three I have now.



 $sql = "SELECT * 
FROM joblist WHERE customer = :customer"; // this is a bindParam

$sql_val = "SELECT a.customer, SUM(a.value) AS tvalue
FROM joblist AS a
INNER JOIN joblist AS b
ON a.customer = b.customer
GROUP BY a.customer";

$sql_bal = "SELECT *
FROM (SELECT SUM(balance) AS tbalance
FROM joblist GROUP BY customer) AS total_balance
WHERE tbalance = :tbalance";


The table that I am using is customer and following is are the columns.



ID - work_order - customer - description - value - balance - status - notes


I'm using php PDO and HTMl of course.



Basically, I have a search function used to query a company. The result are displayed, but I need the totals for the value and balance columns. The only thing that really works is pulling in the data from the table. I've had no success at getting the totals for value and balance.



Current code page







mysql






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 4:48









Harshana

369212




369212










asked Mar 25 at 3:51









S FreebsS Freebs

83




83












  • Explain exactly what you're expecting by joining the queries and the issue you're getting by combining three queries.

    – Harshana
    Mar 25 at 4:22











  • i can't understand your question.please make it clear

    – Tom
    Mar 25 at 5:52

















  • Explain exactly what you're expecting by joining the queries and the issue you're getting by combining three queries.

    – Harshana
    Mar 25 at 4:22











  • i can't understand your question.please make it clear

    – Tom
    Mar 25 at 5:52
















Explain exactly what you're expecting by joining the queries and the issue you're getting by combining three queries.

– Harshana
Mar 25 at 4:22





Explain exactly what you're expecting by joining the queries and the issue you're getting by combining three queries.

– Harshana
Mar 25 at 4:22













i can't understand your question.please make it clear

– Tom
Mar 25 at 5:52





i can't understand your question.please make it clear

– Tom
Mar 25 at 5:52












1 Answer
1






active

oldest

votes


















0














May not understand your question well so I'll make some guess:



SELECT
t1.*,
t2.tvalue,
t3.tbalance
FROM
(SELECT
*
FROM
joblist
WHERE customer = :customer) t1
JOIN
(SELECT
a.customer,
SUM(a.value) AS tvalue
FROM
joblist AS a
GROUP BY a.customer) t2
ON t1.customer = t2.customer
JOIN
(SELECT
b.customer,
SUM(b.balance) AS tbalance
FROM
joblist AS b
GROUP BY b.customer
HAVING tbalance = :tbalance) t3
ON t3.customer = t1.customer;





share|improve this answer























  • cackekai, that's what I was looking for. Good grief I couldn't wrap my head around that. Haven't touched this stuff in like 10 years. Sorry for the confusion about the question guys/girls. I know I wasn't explaining myself quite right as my google results didn't yield that I needed or was wanting to do. Thanks very much!

    – S Freebs
    Mar 25 at 13:07











  • ok new issue.. lol lost my php array.. how would I get the array back from the join statement ?

    – S Freebs
    Mar 25 at 13:51











  • Got it.. it was a LEFT JOIN..

    – S Freebs
    Mar 25 at 14:10











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
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55331049%2fselect-statement-inner-join%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














May not understand your question well so I'll make some guess:



SELECT
t1.*,
t2.tvalue,
t3.tbalance
FROM
(SELECT
*
FROM
joblist
WHERE customer = :customer) t1
JOIN
(SELECT
a.customer,
SUM(a.value) AS tvalue
FROM
joblist AS a
GROUP BY a.customer) t2
ON t1.customer = t2.customer
JOIN
(SELECT
b.customer,
SUM(b.balance) AS tbalance
FROM
joblist AS b
GROUP BY b.customer
HAVING tbalance = :tbalance) t3
ON t3.customer = t1.customer;





share|improve this answer























  • cackekai, that's what I was looking for. Good grief I couldn't wrap my head around that. Haven't touched this stuff in like 10 years. Sorry for the confusion about the question guys/girls. I know I wasn't explaining myself quite right as my google results didn't yield that I needed or was wanting to do. Thanks very much!

    – S Freebs
    Mar 25 at 13:07











  • ok new issue.. lol lost my php array.. how would I get the array back from the join statement ?

    – S Freebs
    Mar 25 at 13:51











  • Got it.. it was a LEFT JOIN..

    – S Freebs
    Mar 25 at 14:10















0














May not understand your question well so I'll make some guess:



SELECT
t1.*,
t2.tvalue,
t3.tbalance
FROM
(SELECT
*
FROM
joblist
WHERE customer = :customer) t1
JOIN
(SELECT
a.customer,
SUM(a.value) AS tvalue
FROM
joblist AS a
GROUP BY a.customer) t2
ON t1.customer = t2.customer
JOIN
(SELECT
b.customer,
SUM(b.balance) AS tbalance
FROM
joblist AS b
GROUP BY b.customer
HAVING tbalance = :tbalance) t3
ON t3.customer = t1.customer;





share|improve this answer























  • cackekai, that's what I was looking for. Good grief I couldn't wrap my head around that. Haven't touched this stuff in like 10 years. Sorry for the confusion about the question guys/girls. I know I wasn't explaining myself quite right as my google results didn't yield that I needed or was wanting to do. Thanks very much!

    – S Freebs
    Mar 25 at 13:07











  • ok new issue.. lol lost my php array.. how would I get the array back from the join statement ?

    – S Freebs
    Mar 25 at 13:51











  • Got it.. it was a LEFT JOIN..

    – S Freebs
    Mar 25 at 14:10













0












0








0







May not understand your question well so I'll make some guess:



SELECT
t1.*,
t2.tvalue,
t3.tbalance
FROM
(SELECT
*
FROM
joblist
WHERE customer = :customer) t1
JOIN
(SELECT
a.customer,
SUM(a.value) AS tvalue
FROM
joblist AS a
GROUP BY a.customer) t2
ON t1.customer = t2.customer
JOIN
(SELECT
b.customer,
SUM(b.balance) AS tbalance
FROM
joblist AS b
GROUP BY b.customer
HAVING tbalance = :tbalance) t3
ON t3.customer = t1.customer;





share|improve this answer













May not understand your question well so I'll make some guess:



SELECT
t1.*,
t2.tvalue,
t3.tbalance
FROM
(SELECT
*
FROM
joblist
WHERE customer = :customer) t1
JOIN
(SELECT
a.customer,
SUM(a.value) AS tvalue
FROM
joblist AS a
GROUP BY a.customer) t2
ON t1.customer = t2.customer
JOIN
(SELECT
b.customer,
SUM(b.balance) AS tbalance
FROM
joblist AS b
GROUP BY b.customer
HAVING tbalance = :tbalance) t3
ON t3.customer = t1.customer;






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 25 at 5:46









cachekaicachekai

16




16












  • cackekai, that's what I was looking for. Good grief I couldn't wrap my head around that. Haven't touched this stuff in like 10 years. Sorry for the confusion about the question guys/girls. I know I wasn't explaining myself quite right as my google results didn't yield that I needed or was wanting to do. Thanks very much!

    – S Freebs
    Mar 25 at 13:07











  • ok new issue.. lol lost my php array.. how would I get the array back from the join statement ?

    – S Freebs
    Mar 25 at 13:51











  • Got it.. it was a LEFT JOIN..

    – S Freebs
    Mar 25 at 14:10

















  • cackekai, that's what I was looking for. Good grief I couldn't wrap my head around that. Haven't touched this stuff in like 10 years. Sorry for the confusion about the question guys/girls. I know I wasn't explaining myself quite right as my google results didn't yield that I needed or was wanting to do. Thanks very much!

    – S Freebs
    Mar 25 at 13:07











  • ok new issue.. lol lost my php array.. how would I get the array back from the join statement ?

    – S Freebs
    Mar 25 at 13:51











  • Got it.. it was a LEFT JOIN..

    – S Freebs
    Mar 25 at 14:10
















cackekai, that's what I was looking for. Good grief I couldn't wrap my head around that. Haven't touched this stuff in like 10 years. Sorry for the confusion about the question guys/girls. I know I wasn't explaining myself quite right as my google results didn't yield that I needed or was wanting to do. Thanks very much!

– S Freebs
Mar 25 at 13:07





cackekai, that's what I was looking for. Good grief I couldn't wrap my head around that. Haven't touched this stuff in like 10 years. Sorry for the confusion about the question guys/girls. I know I wasn't explaining myself quite right as my google results didn't yield that I needed or was wanting to do. Thanks very much!

– S Freebs
Mar 25 at 13:07













ok new issue.. lol lost my php array.. how would I get the array back from the join statement ?

– S Freebs
Mar 25 at 13:51





ok new issue.. lol lost my php array.. how would I get the array back from the join statement ?

– S Freebs
Mar 25 at 13:51













Got it.. it was a LEFT JOIN..

– S Freebs
Mar 25 at 14:10





Got it.. it was a LEFT JOIN..

– S Freebs
Mar 25 at 14:10



















draft saved

draft discarded
















































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.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55331049%2fselect-statement-inner-join%23new-answer', 'question_page');

);

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







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript