Page 1 of 1
SQL select problem in PHP
Posted: Wed Nov 23, 2005 10:38 am
by Charles256
Code: Select all
$query2="SELECT DISTINCT `kart_no`,`kart_name` FROM kart ORDER BY `kart_no` ASC ";
$sql2=mysql_query($query2);
while ($test=mysql_fetch_object($sql2))
{
echo ("<option value='$test->kart_no'");
if (isset($model))
{
if ($model==$test->kart_no)
{
echo " selected";
}
}
echo (">$test->item_no $test->kart_name</option>");
}
the problem is i need another colum `item_no` to be grabbed also, however, if i add item_no in the select it effectivelly ignores the distinct kart_no command because that's what I really really need to be distinct...is it possible to do all this with SQL? or am I going to have to do some kind of weird processing afterwards? the manual on DISTINCT doesn't discuss the possibility of something being distinct and something else not being distinct..unless I just read over it...my friend google isn't being very open about the subject either.... any suggestions?
Posted: Wed Nov 23, 2005 10:43 am
by Jenk
GROUP BY `kart_no` ?
Posted: Wed Nov 23, 2005 10:45 am
by Charles256
yes yes yes yes yes! THANK YOU!!!

:: slips jenk a five, in monopoly money.:: guess it helps to know what command your looking for:-D