- Anonymous
- Saturday, August 4th, 2007 at 5:20:13am MDT
- select 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');
advertising
Update the Post
Either update this post and resubmit it with changes, or make a new post.
You may also comment on this post.
Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.