SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Resistance is Futile webgodjj's Avatar
    Join Date
    Nov 2002
    Location
    Madison, WI USA
    Posts
    448
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Error on select: column ambiguous?

    Hi,
    I have never got this error, so I can't understand where I went wrong here. Can anyone help me understand what is going wrong here?

    ERROR: Column: 'rate_cat_id' in group statement is ambiguous

    PHP Code:
    <table cellpadding="2" cellspacing="0" class="rates"> 
    <?
    $property_id
    =3;
    $result8=mysql_query("select rate_cats.name, rate_cats.rate_cat_id, rate_cats.description from rates, properties, rate_cats where rates.property_id=$property_id and rate_cats.rate_cat_id=rates.rate_cat_id") or die(mysql_error());
    while(
    $row_rates_cat=mysql_fetch_object($result8)) {
    ?>
        <tr>
        <th class="ratesheadline" colspan="2"><?=$row_rates_cat->name;?></th>
        </tr><tr>
        <td class="ratestext" colspan="2"><?=$row_rates_cat->description;?></td>
        </tr><tr>
        <td> 
        <table cellpadding="2" cellspacing="0" class="rates"> 
        <?
        $result10
    =mysql_query("select rates.price, rates.description from rates, properties, rate_cats where rates.property_id=$property_id and rates.rate_cat_id=$row_rates_cat->rate_cat_id GROUP BY rate_cat_id") or die(mysql_error()); 
        while(
    $row_cat_list=mysql_fetch_object($result10)) {
        
    ?>
            <tr>
            <td width="99%" class="bglight"><?=$row_rates_item->description;?></td>
            <td width="1%" class="bglight" align="right"><?=$row_rates_item->price;?></td>
            </tr>
        <? ?>
        </table>
        </td>
        </tr>
    <? ?>
    </table>

  2. #2
    SitePoint Guru aamonkey's Avatar
    Join Date
    Sep 2004
    Location
    kansas
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you are selecting multiple tables and more than one of them has a rate_cat_id, so mysql doesn't know which one you are trying to group by. You need to refine the group statement further:
    Code:
      GROUP BY whichever_table.rate_cat_id


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •