Results 1 to 1 of 1
  1. #1
    Join Date
    Apr 2004
    Posts
    1

    Unanswered: multiple keyid refer another table get name

    hi, i got a little trouble with constructing this page.
    Hope someone here can guide me.

    i got this 10 column_id wanted to refer it name from another table
    but when i try to JOIN it always fail getting their name

    actually should be:
    ==============
    ID1 | ID2 | ID3
    apple | oragne | grape
    ==============

    i will paste it here

    PHP Code:
    $sql "SELECT *, ro_mob.mob_drop1id, 
    ro_item.item_name AS ro_mob_item_name

    FROM `ro_mob` ro_mob

    LEFT JOIN `ro_item` ro_item
    ON ro_mob.mob_drop1id = ro_item.item_id
    AND ro_mob.mob_drop2id = ro_item.item_id
    AND ro_mob.mob_drop3id = ro_item.item_id
    AND ro_mob.mob_drop4id = ro_item.item_id
    AND ro_mob.mob_drop5id = ro_item.item_id
    AND ro_mob.mob_drop6id = ro_item.item_id
    AND ro_mob.mob_drop7id = ro_item.item_id
    AND ro_mob.mob_drop8id = ro_item.item_id

    LIKE '
    $abc' ORDER BY '$order' DESC limit 0,30";

    $result mysql_query($sql);
    //------------------------------

    while ($r mysql_fetch_array($result)) {

    .....,
    $r['mob_drop1id'],$r['mob_drop2id'],$r['mob_drop3id'],$r['mob_drop4id'],$r['mob_drop5id'],$r['mob_drop6id'],$r['mob_drop7id'],$r['mob_drop8id']);

    table structure of ro_item:
    Code:
    CREATE TABLE `ro_item` (
      `item_id` int(8) NOT NULL default '0',
      `item_name` varchar(255) NOT NULL default '0',
      PRIMARY KEY  (`item_id`)
    ) TYPE=MyISAM;
    minimize structure of ro_mob:
    Code:
    CREATE TABLE `ro_mob` (
     `mob_drop1id` int(8) NOT NULL default '0',
     `mob_drop2id` int(8) NOT NULL default '0',
    ................
      PRIMARY KEY  (`mob_id`)
    ) TYPE=MyISAM;
    This is the page working at getting the item ID into name refering to `ro_item`

    http://www.vaxva.com:8080/game/rov/db/mob.php

    Thanks for helping in advance
    Last edited by va_group; 04-01-04 at 21:57.

Posting Permissions

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