Page 1 of 1

problems with distinct

Posted: Fri Dec 05, 2003 10:28 am
by grudz
here is my code

Code: Select all

$query_forum = "SELECT DISTINCT question_title FROM forum ORDER BY `date` DESC";
basically, this makes the users see on the php page the different info from the 'qustion_title' column. thats exactly what i wanted, but on this page, i also have different columns from that table that i want to show, not just 'question_title'

how do i keep this code, but write that i also want the other columns

thank you in advance

Posted: Fri Dec 05, 2003 10:30 am
by Weirdan

Code: Select all

$query_forum = "SELECT DISTINCT question_title, other_column, some_other_column FROM forum ORDER BY `date` DESC";
Huh?

Posted: Fri Dec 05, 2003 10:40 am
by grudz
doesnt work......its logical though

Posted: Fri Dec 05, 2003 12:02 pm
by grudz
anybody have any ideas...please....

Posted: Fri Dec 05, 2003 12:05 pm
by Draco_03
should work... giveus a bit more of your code and tell us what is the other colomn you want to show
ps : you can use

Code: Select all

instead of

Code: Select all

when showing php code

here it is

Posted: Fri Dec 05, 2003 12:21 pm
by grudz

Code: Select all

<?php
mysql_select_db($database_cnpa, $cnpa);
$query_forum = "SELECT DISTINCT question_title FROM forum ORDER BY `date` DESC";
$forum = mysql_query($query_forum, $cnpa) or die(mysql_error());
$row_forum = mysql_fetch_assoc($forum);
$totalRows_forum = mysql_num_rows($forum);

?>
my other columns that i need are : name, date, question, reply, reply_name, reply_date

if u want more code....ill give u everything....but i guess this part is the important one

Posted: Fri Dec 05, 2003 12:27 pm
by grudz
whats weird is that it does sort it by date (in descending order) so it sort of "rocognizes" the other columns...but when i echo it.....i dont see anything