Jump to content
Fórum Script Brasil
  • 0

[Resolvido]Código para exibir registros duplicados


RRH
 Share

Question

SELECT id_sst, COUNT(*) FROM logradouros WHERE id_sst <> '' GROUP BY id_sst HAVING COUNT(*) >1
Utilizando o código acima no phpmyadmin tenho o seguinte resultado: phpx.jpg Agora, como exibir o resultado acima em uma página do site? Não sei como dar um echo para exibir o COUNT(*), como na imagem acima.
<?php
include "config.php";

$sql = "SELECT id_sst, COUNT(*) FROM logradouros WHERE id_sst <> '' GROUP BY id_sst HAVING COUNT(*) >1 ";
$query = mysql_query ($sql);


while ($linha = mysql_fetch_array ($query)) {

echo $linha['id_sst']."<br />";


}
?>

Edited by RRH
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Tarde,

teste dessa forma

while ($linha = mysql_fetch_array ($query)) {

echo $linha['id_sst']."<br />";
echo $linha[COUNT(*)]."<br/>";
}
ou assim também
$sql = "SELECT id_sst, COUNT(*) as conta FROM logradouros WHERE id_sst <> '' GROUP BY id_sst HAVING COUNT(*) >1 ";
$query = mysql_query ($sql);


while ($linha = mysql_fetch_array ($query)) {

echo $linha['id_sst']."<br />";
echo $linha['conta']."<br />";


}

acho que qualquer um dos 2 deve dar

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Forum Statistics

    • Total Topics
      150.9k
    • Total Posts
      648.8k
×
×
  • Create New...