If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > multiple keyid refer another table get name

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-01-04, 20:52
va_group va_group is offline
Registered User
 
Join Date: Apr 2004
Posts: 1
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 20:57.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On