1
I need to create a query Mysql/PHP with 3 different criteria, but within the same BD table.
Tabela Negociações (Nome: tbl_neg) ID STS VALOR 1 1 R$23.000,00 2 2 R$60.000,00 3 1 R$10.000,00 4 1 R$50.000,00 5 6 R$20.000,00 6 2 R$88.000,00 7 6 R$15.000,00
I need to make a query in this table, but in the status column (name: Sts) there will always be three criteria, quote 1, 2 and 6, that I need to separate them and then add them up.
I don’t know if you can understand my "question". I’m thinking of something like a Join in the same table, because I’ve been doing a search on Dad (Google) and I know it exists. Would it be possible to use something like:
SELECT * FROM tb_neg a
INNER JOIN tb_neg b ON a.stsneg = '1' AS analise
INNER JOIN tb_neg c ON a.stsneg = '2' AS aprovado
INNER JOIN tb_neg d ON a.stsneg = '6' AS reprovado
And then: (take each value)
$vranalise = $row["analise"];
$vraprovado = $row["aprovado"];
$vrreprovado = $row["reprovado"];
And then: (Imaginary Excel type: take the sub-total of each status)
$totalanalise = SOMA($vranalise);
$totalaprovado = SOMA($vraprovado);
$totalreprovado = SOMA($vrreprovado);
And then: (take total value)
$vrgeral = ($totalanalise + $totalaprovado + $totalreprovado);
I know it’s kind of imaginary, but I don’t know how to do it like you do and "catch" the hell out of it! ?
ai ai ai ai ai... shuffled everything again... This time I did everything certin in Word... copied, glued and went wrong... Aff
– user34782
I managed to give spaces... was 10! rs
– user34782
The text is markdown-formatted and not HTML-formatted. That’s why you’re having difficulties.
– Augusto Vasques
I couldn’t figure out what you were asking. Can you give an example of calculation and expected results?
– Jorge B.
It’s like Murilão is saying! Caracas!! when I look at this exit... Ussa... this is what I need guys! I’ll test later... it will be huh!
– user34782
Thanks for formatting Guto... the text was beautiful! rs
– user34782