Somar Registros de uma tabela.
tenho uma tabela SQL e na coluna equipamentos tenho uma descrição "HD", é possivel eu contar quantos equipamentos "HD" tenho?? quem pode me ajudar??? Grato.
Leonardo
Curtidas 0
Melhor post
Emerson Nascimento
07/12/2018
Tem sim. Se for somente esta condição, seria algo como:
select count(*) from tabela where descricao like '%HD%'
GOSTEI 2
Mais Respostas
Leonardo
07/12/2018
vou testar aqui e te falo Emerson, desde já sou grato pela ajuda.
GOSTEI 0
Vinsent Duquate
07/12/2018
BUY 100% QUALITY REAL AND FAKE PASSPORT, COUNTERFEIT MONEY, DRIVER'S LICENSE, PASSPORT, WHATSAPP ....... +447448587349 ID CARD, IELTS, VISA, BIRTH CERTIFICATE, SCHOOL DIPLOMAS, UK, GERMANY CANADA, POLAND US GREEN CARD AND MANY OTHER DOCUMENTS (vincentdocument4@gmail.com
Apply for real register Passport, Visa, Driving License, ID CARDS, marriage certificates, diplomas etc. for sell. Passport, citizenship, ID cards, driver license, diplomas, degrees, certificates service available. Tourist and business services available to all 50 states and all nationalities worldwide. Authentic High Quality passports, Real Genuine Data Base Registered and unregistered Passports and other Citizenship documents.We can guarantee you a new Identity Card, ID Card, Driver's License, Passports, SSN, credit files, and credit cards, school diplomas, school degrees. All in all a new name issued and registered in the government database system. We use high quality equipment and materials to produce authentic and counterfeit documents. All secret features of real passports are carefully duplicated for our Registered and unregistered documents. Registered and unregistered passports, driver's licenses, ID cards, stamps, visas, school Diplomas and other products for a number of countries like: USA, Australia, Belgium , Brazil, Canada, Italian, Finland, France, Germany, Israel, Mexico, Netherlands, South Africa, Spain, United Kingdom, etc.
** CONTACT CHANELS **
General support ............ vincentdocument4@gmail.com
Suport contact ........... + 447448587349
E-mail ..................... jobitoe56@gmail.com
WHATSAPP ....... +447448587349
We are the best producer of authentic counterfeit banknotes, novelty and high quality passport, driver license, ID card, green card, certificate, diploma documents. With over a billion of our products circulating around the world. We only offer original high-quality counterfeit currency notes and fake documents. These bills are not home made but industrial and professional manufacturing. From High Quality IT techinicians from US, Russia, Korea and China We offer high quality authentic counterfeits for the following currencies;
EUR - Euro
USD - US Dollars
GBP - British Pound
INR - Indian Rupee
AUD - Australian Dollars
CAD - Canadian Dollars
AED - Emirati Dirham
ZAR - edge
CHF - Swiss Franc
CNY - Chinese Yuan Renminbi
MYR - Malaysian Ringgit
THB - Thai Baht
ORDER ANY UNIVERSAL DOCUMENTS YOU NEED;
PASSPORTS
ID card
Social security card
Licenses Drivers
Canada Cards
United States Cards
Student Cards
International Cards
Private Cards
Adoption Certificates
Baptism Certificates
Birth Certificates
Death Certificates
Divorce Certificates
Marriage Certificates
Custom Certificates
High School Diplomas
G.E.D. Diplomas
Home School Diplomas
College Degrees
University Degrees
Trade skill certificates
Validate SSN Number
US green cards
Counterfeit dollars / euro
Spy Products
Voice Changers
Listening Devices
Invisible Ink
DMV Record Inquiry
Background check
Investigate Anyone
ssd chemical solution
activation powder
Get IELTS TOEFL ESOL GRE certificates without test in Europe
BUY real and original PASSPORTS
Get real and original passports USA (United States)
Get real and original Australian passports (Australia)
Get real and original Belgian passports (Belgium)
Get real and original Brazilian passport (Brazil)
Get real and original Canadian passports (Canada)
Get real and original passports of Finland
Get real and original French passports (France)
Get real and original German passports (Germany)
Get real and original Dutch passport (The Netherlands) t
Get real and original passports UK (United Kingdom)
Get real and original Spanish passport (Spain)
Get real and original mexican passports (Mexico)
Get real and original South African passports (South Africa)
Get real and original passports Swiss (Switzerland)
Get real and original German passports (Germany)
Get real and original Chinese passports (China)
Get real and original Spanish passport (Spain)
Get real and original passports Austrian (Austria)
Get real and original japanese passports (Japan)
Get real and original passports of Ukraine (Ukraine)
Get real and original passports cambodia (Cambodia)
Get real and original passports UK (United Kingdom)
Get real and original passports USA
Get real and original passports Romanian (Romania)
Get real and original passports Polish (Poland)
Get real and original passports chypre (Cyprus)
Get real and original passports NORWAY (Norway)
Get real and original Portuguese passports (Portugal)
Get real and original Lithuanian Passports (Lithuania)
Get real and original passports (Russia)
Get real and original Hungarian passport
NB: 100% customer satisfaction.
Apply for real register Passport, Visa, Driving License, ID CARDS, marriage certificates, diplomas etc. for sell. Passport, citizenship, ID cards, driver license, diplomas, degrees, certificates service available. Tourist and business services available to all 50 states and all nationalities worldwide. Authentic High Quality passports, Real Genuine Data Base Registered and unregistered Passports and other Citizenship documents.We can guarantee you a new Identity Card, ID Card, Driver's License, Passports, SSN, credit files, and credit cards, school diplomas, school degrees. All in all a new name issued and registered in the government database system. We use high quality equipment and materials to produce authentic and counterfeit documents. All secret features of real passports are carefully duplicated for our Registered and unregistered documents. Registered and unregistered passports, driver's licenses, ID cards, stamps, visas, school Diplomas and other products for a number of countries like: USA, Australia, Belgium , Brazil, Canada, Italian, Finland, France, Germany, Israel, Mexico, Netherlands, South Africa, Spain, United Kingdom, etc.
** CONTACT CHANELS **
General support ............ vincentdocument4@gmail.com
Suport contact ........... + 447448587349
E-mail ..................... jobitoe56@gmail.com
WHATSAPP ....... +447448587349
We are the best producer of authentic counterfeit banknotes, novelty and high quality passport, driver license, ID card, green card, certificate, diploma documents. With over a billion of our products circulating around the world. We only offer original high-quality counterfeit currency notes and fake documents. These bills are not home made but industrial and professional manufacturing. From High Quality IT techinicians from US, Russia, Korea and China We offer high quality authentic counterfeits for the following currencies;
EUR - Euro
USD - US Dollars
GBP - British Pound
INR - Indian Rupee
AUD - Australian Dollars
CAD - Canadian Dollars
AED - Emirati Dirham
ZAR - edge
CHF - Swiss Franc
CNY - Chinese Yuan Renminbi
MYR - Malaysian Ringgit
THB - Thai Baht
ORDER ANY UNIVERSAL DOCUMENTS YOU NEED;
PASSPORTS
ID card
Social security card
Licenses Drivers
Canada Cards
United States Cards
Student Cards
International Cards
Private Cards
Adoption Certificates
Baptism Certificates
Birth Certificates
Death Certificates
Divorce Certificates
Marriage Certificates
Custom Certificates
High School Diplomas
G.E.D. Diplomas
Home School Diplomas
College Degrees
University Degrees
Trade skill certificates
Validate SSN Number
US green cards
Counterfeit dollars / euro
Spy Products
Voice Changers
Listening Devices
Invisible Ink
DMV Record Inquiry
Background check
Investigate Anyone
ssd chemical solution
activation powder
Get IELTS TOEFL ESOL GRE certificates without test in Europe
BUY real and original PASSPORTS
Get real and original passports USA (United States)
Get real and original Australian passports (Australia)
Get real and original Belgian passports (Belgium)
Get real and original Brazilian passport (Brazil)
Get real and original Canadian passports (Canada)
Get real and original passports of Finland
Get real and original French passports (France)
Get real and original German passports (Germany)
Get real and original Dutch passport (The Netherlands) t
Get real and original passports UK (United Kingdom)
Get real and original Spanish passport (Spain)
Get real and original mexican passports (Mexico)
Get real and original South African passports (South Africa)
Get real and original passports Swiss (Switzerland)
Get real and original German passports (Germany)
Get real and original Chinese passports (China)
Get real and original Spanish passport (Spain)
Get real and original passports Austrian (Austria)
Get real and original japanese passports (Japan)
Get real and original passports of Ukraine (Ukraine)
Get real and original passports cambodia (Cambodia)
Get real and original passports UK (United Kingdom)
Get real and original passports USA
Get real and original passports Romanian (Romania)
Get real and original passports Polish (Poland)
Get real and original passports chypre (Cyprus)
Get real and original passports NORWAY (Norway)
Get real and original Portuguese passports (Portugal)
Get real and original Lithuanian Passports (Lithuania)
Get real and original passports (Russia)
Get real and original Hungarian passport
NB: 100% customer satisfaction.
GOSTEI 0
Leonardo
07/12/2018
Emerson, não deu certo.. deixa eu ser mais claro na minha colocação, preciso fazer uma busca por login e através dele, trará o resultado de quantos equipamentos "HD´s" eu tenho, retornaria como valor 1...2....3.. sou grato mais uma vez..
GOSTEI 0
Leonardo
07/12/2018
Emerson, este é o código..
if (empty($_POST['login'])) {"";}
if(isset($_POST['login'])) {"";
if($_POST['login'] == "") {"";} else{
$buscar = $_POST['login'];
$cmd = "SELECT SUM(equipamentos) FROM almoxarifado WHERE equipamentos = 'HD'";
$resultado = mysqli_query($conn, $cmd);
$row = mysqli_num_rows($resultado);
if($row == " ") {" ";} else{
while ($dados = mysqli_fetch_array($resultado)) {
$Equipamentos = $dados['equipamentos'];
}
}
}
}
não sei o que está dando de errado.... pode me ajudar..
if (empty($_POST['login'])) {"";}
if(isset($_POST['login'])) {"";
if($_POST['login'] == "") {"";} else{
$buscar = $_POST['login'];
$cmd = "SELECT SUM(equipamentos) FROM almoxarifado WHERE equipamentos = 'HD'";
$resultado = mysqli_query($conn, $cmd);
$row = mysqli_num_rows($resultado);
if($row == " ") {" ";} else{
while ($dados = mysqli_fetch_array($resultado)) {
$Equipamentos = $dados['equipamentos'];
}
}
}
}
não sei o que está dando de errado.... pode me ajudar..
GOSTEI 0
Emerson Nascimento
07/12/2018
Leonardo, você fez totalmente diferente do que eu te passei.
Eu utilizei a função COUNT(), você utilizou SUM(); eu utilizei LIKE, você utilizou =
O campo equipamentos contém exatamente a sigla HD?
$cmd = "SELECT COUNT(equipamentos) FROM almoxarifado WHERE equipamentos LIKE '%HD%' ";
da forma como está acima o sistema irá contar quantos produtos têm HD como conteúdo do campo equipamento.
se a tua idéia é contar o saldo de produtos, então deve ser algo assim:
$cmd = "SELECT codproduto, SUM(quantidade) FROM almoxarifado WHERE equipamentos LIKE '%HD%' group by codproduto ";
count() - conta o número de registros
sum() - soma o conteúdo de um campo
Eu utilizei a função COUNT(), você utilizou SUM(); eu utilizei LIKE, você utilizou =
O campo equipamentos contém exatamente a sigla HD?
$cmd = "SELECT COUNT(equipamentos) FROM almoxarifado WHERE equipamentos LIKE '%HD%' ";
da forma como está acima o sistema irá contar quantos produtos têm HD como conteúdo do campo equipamento.
se a tua idéia é contar o saldo de produtos, então deve ser algo assim:
$cmd = "SELECT codproduto, SUM(quantidade) FROM almoxarifado WHERE equipamentos LIKE '%HD%' group by codproduto ";
count() - conta o número de registros
sum() - soma o conteúdo de um campo
GOSTEI 1
Leonardo
07/12/2018
Emerson a idéia é esta mesmo contar o saldo de equipamentos em HD, pois irei fazer um controle de entrada e saida de acordo com cada 'login', ou seja, se o 'login' recebeu 5 HD´s no dia 10/12/2018 e no dia 10/12/2018 saiu 3 HD´s meu saldo deverá ser de 2 HD´s. compreende? mais uma vez grato pela ajuda e prestavididade.
GOSTEI 0
Emerson Nascimento
07/12/2018
você conseguiu resolver?
se não conseguiu, publique a estrutura da tua tabela e alguns registros (somente os campos pertinentes).
se não conseguiu, publique a estrutura da tua tabela e alguns registros (somente os campos pertinentes).
GOSTEI 1
Leonardo
07/12/2018
Não consegui..
segue a estrutura da tabela..
Estrutura da tabela
Nome Tipo Agrupamento (Collation) Atributos
1 id_almox Primária int(11) AUTO_INCREMENT
2 equipamentos varchar(15) utf8_general_ci
3 modelo varchar(15) utf8_general_ci
4 num_serie varchar(20) utf8_general_ci
5 entrada varchar(10) utf8_general_ci (Data)
6 saida varchar(10) utf8_general_ci (Data)
7 login Índice varchar(8) utf8_general_ci (Foreing Key)
8 baixa varchar(10) utf8_general_ci
9 contrato int(10)
segue a estrutura da tabela..
Estrutura da tabela
Nome Tipo Agrupamento (Collation) Atributos
1 id_almox Primária int(11) AUTO_INCREMENT
2 equipamentos varchar(15) utf8_general_ci
3 modelo varchar(15) utf8_general_ci
4 num_serie varchar(20) utf8_general_ci
5 entrada varchar(10) utf8_general_ci (Data)
6 saida varchar(10) utf8_general_ci (Data)
7 login Índice varchar(8) utf8_general_ci (Foreing Key)
8 baixa varchar(10) utf8_general_ci
9 contrato int(10)
GOSTEI 0
Emerson Nascimento
07/12/2018
Com base nessa estrutura, deve ser algo assim:
select COUNT(equipamentos) from almoxarifado where rtrim(ltrim(coalesce(saida,'')))='' and login = 'login_desejado' and equipamentos like '%HD%'
select COUNT(equipamentos) from almoxarifado where rtrim(ltrim(coalesce(saida,'')))='' and login = 'login_desejado' and equipamentos like '%HD%'
GOSTEI 0
Leonardo
07/12/2018
este é o código:
if (empty($_POST['login'])) {"";}
if(isset($_POST['login'])) {"";
if($_POST['login'] == "") {"";} else{
$buscar = $_POST['login'];
$cmd = "select COUNT(equipamentos) from almoxarifado where rtrim(ltrim(coalesce(saida,'')))='' and login = 'login_desejado' and equipamentos like '%HD%'";
$resultado = mysqli_query($conn, $cmd);
$row = mysqli_num_rows($resultado);
if($row == " ") {" ";} else{
while ($dados = mysqli_fetch_array($resultado)) {
$HD = $dados['equipamentos'];}
}
}
}
o resultado desta busca, deverá ser o saldo de quantidade de equipamentos HD´s. onde eu colocarei no campo "Value" de uma input para exibir este saldo..
estou usando PHP e MYSQL. grato.
if (empty($_POST['login'])) {"";}
if(isset($_POST['login'])) {"";
if($_POST['login'] == "") {"";} else{
$buscar = $_POST['login'];
$cmd = "select COUNT(equipamentos) from almoxarifado where rtrim(ltrim(coalesce(saida,'')))='' and login = 'login_desejado' and equipamentos like '%HD%'";
$resultado = mysqli_query($conn, $cmd);
$row = mysqli_num_rows($resultado);
if($row == " ") {" ";} else{
while ($dados = mysqli_fetch_array($resultado)) {
$HD = $dados['equipamentos'];}
}
}
}
o resultado desta busca, deverá ser o saldo de quantidade de equipamentos HD´s. onde eu colocarei no campo "Value" de uma input para exibir este saldo..
estou usando PHP e MYSQL. grato.
GOSTEI 0