| | |
don't print duplicate records
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: May 2009
Posts: 10
Reputation:
Solved Threads: 0
Hi, I am working on result.php page, where I want to order data by date, but I want remove (don't print) duplicate records.I am using 3 tables:
1,results - short res
2,excercises - short exc
3,user - shor usr
I have this query:
But this query doesn't work and print only half of records.
Could somebody help me?
Thanks
1,results - short res
2,excercises - short exc
3,user - shor usr
I have this query:
<div class="main">
<table cellspacing="20">
<tr>
<th></th>
<th></th>
<th>Number of good excercises</th>
<th>Number of bad excercises</th>
<th>Effecient</th>
</tr>
<?php
$query1="SELECT DATE_FORMAT(res_time, '%D %M %Y') AS res_time, exc_excercise_name, res_result FROM res INNER JOIN exc ON res_exc_id=exc_id WHERE res_usr_id=$_GET[id] GROUP BY res_time HAVING COUNT( res_time) = 1";
$result1 = mysql_query($query1);
while (list($res_time,$exc_excercise_name,$res_result) = mysql_fetch_row($result1)) {
echo "<tr>",
"<td class='time'>",
$res_time,"</td>",
"</tr>",
"<tr>",
"<td>",
"</td>",
"<td class='font'>",
$exc_excercise_name,"</td>",
"<td>",
"</td>",
"<td>",
"</td>",
"<td class='result'>",
$res_result,"%","</td>",
"</tr>";
}
@mysql_close($connect);
?>
</table>
<hr />
</div> Could somebody help me?
Thanks
Last edited by Tekmaven; Jun 8th, 2009 at 4:41 pm. Reason: Code Tags
•
•
Join Date: May 2009
Posts: 10
Reputation:
Solved Threads: 0
•
•
•
•
SELECT DISTINCT DATE_FORMAT
GROUP BY uses column_list having same order and same number used with SELECT statement.
PHP Syntax (Toggle Plain Text)
SELECT DATE_FORMAT(res_time, '%D %M %Y') AS res_time, exc_excercise_name, res_result FROM res INNER JOIN exc ON res_exc_id=exc_id WHERE res_usr_id='value' GROUP BY DATE_FORMAT(res_time, '%D %M %Y') AS res_time, exc_excercise_name, res_result HAVING COUNT (DATE_FORMAT(res_time, '%D %M %Y')) = 'value'
Failure is not fatal, but failure to change might be. - John Wooden
•
•
Join Date: May 2009
Posts: 10
Reputation:
Solved Threads: 0
•
•
•
•
GROUP BY uses column_list having same order and same number used with SELECT statement.
PHP Syntax (Toggle Plain Text)
SELECT DATE_FORMAT(res_time, '%D %M %Y') AS res_time, exc_excercise_name, res_result FROM res INNER JOIN exc ON res_exc_id=exc_id WHERE res_usr_id='value' GROUP BY DATE_FORMAT(res_time, '%D %M %Y') AS res_time, exc_excercise_name, res_result HAVING COUNT (DATE_FORMAT(res_time, '%D %M %Y')) = 'value'
res_usr_id='value' - here I want obtain ID of user,who I click on other page, therefore was there res_usr_id=$_GET[id] and it works.
(DATE_FORMAT(res_time, '%D %M %Y')) = 'value' - here I want eliminate duplicate date records and therefore was there (DATE_FORMAT(res_time, '%D %M %Y')) = '1'.
Is it ok?
![]() |
Similar Threads
- how to delete duplicate record in a table by using SQL query (MS SQL)
- Quick Search(Finding Duplicate Records) (Java)
- Delete duplicate records in MS ACCESS (MS Access and FileMaker Pro)
- How to remove duplicate records (MS SQL)
- Exclude duplicate records in a JOIN (MS SQL)
- how can i print a list of records (Pascal and Delphi)
- how to copy data into array or memory ? (C)
Other Threads in the PHP Forum
- Previous Thread: Retrieving the size of a rotated image
- Next Thread: Help with php script to export mysql data and import data
| Thread Tools | Search this Thread |
301 apache api array autosuggest beginner binary broken cakephp checkbox class cms code compression cron curl data database date display dropdownlist dynamic echo email eregi error execution file files folder form forms function functions google href htaccess html httppost if...loop image include insert ip javascript joomla jquery key library limit link links login mail md5 menu mlm multiple mysql mysql_real_escape_string oop paypal pdf pdfdownload php phpvotingscript problem query radio random recursion remote screen script search searchbox server session sessions sms sorting source space sql syntax system table tutorial update upload url validator variable video volume votedown web website youtube zend






