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

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현