rendered paste bodyselect t.row1, p1.name as key1, p2.name as key2
from table1 t
left join table2 p1 on (t.key1=p1.id)
left join table2 p2 on (t.key2=p2.id)
-- phpMyAdmin SQL Dump
-- version 2.6.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Aug 04, 2007 at 12:20 PM
-- Server version: 4.1.9
-- PHP Version: 4.3.10
--
-- Database: `cert`
--
-- --------------------------------------------------------
--
-- Table structure for table `table1`
--
CREATE TABLE `table1` (
`row1` int(5) NOT NULL auto_increment,
`key1` int(5) NOT NULL default '0',
`key2` int(5) NOT NULL default '0',
PRIMARY KEY (`row1`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
--
-- Dumping data for table `table1`
--
INSERT INTO `table1` VALUES (1, 1, 2);
INSERT INTO `table1` VALUES (2, 3, 4);
-- --------------------------------------------------------
--
-- Table structure for table `table2`
--
CREATE TABLE `table2` (
`id` int(5) NOT NULL default '0',
`name` varchar(32) NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `table2`
--
INSERT INTO `table2` VALUES (1, 'nameid1');
INSERT INTO `table2` VALUES (2, 'nameid2');
INSERT INTO `table2` VALUES (3, 'nameid3');