Jump to content

Relational tables.


Jragon

Recommended Posts

Hia,

 

I have 3 tables, and  I need to do a join on all 3 of them. I have score_game, score_song and score_score. Score game has only a few entries in it, the coloums are game and ID. In score_song it is song game, and ID I need to join those to gether. So in the score_song I need to put game in the game bit, but the game bit is the ID of the games. so if score_song.game was 3 the score_game would put the row with the ID of 3. score_score is the whole thing. It will need to output songs and games joined so they are not integers.

 

dumps

-- phpMyAdmin SQL Dump
-- version 3.2.4
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jan 03, 2011 at 01:02 PM
-- Server version: 5.1.41
-- PHP Version: 5.3.1

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

--
-- Database: `randoms`
--

-- --------------------------------------------------------

--
-- Table structure for table `score_games`
--

CREATE TABLE IF NOT EXISTS `score_games` (
  `Game` varchar(32) NOT NULL,
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`ID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;

--
-- Dumping data for table `score_games`
--

INSERT INTO `score_games` (`Game`, `ID`) VALUES
('Guitar Hero', 1),
('Frets on Fire', 2),
('You mother.', 3);

-- --------------------------------------------------------

--
-- Table structure for table `score_score`
--

CREATE TABLE IF NOT EXISTS `score_score` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `user` varchar(32) NOT NULL,
  `game` int(11) NOT NULL,
  `score` int(11) NOT NULL,
  `song` int(11) NOT NULL,
  `notestreak` int(11) NOT NULL,
  `notehit` int(11) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;

--
-- Dumping data for table `score_score`
--

INSERT INTO `score_score` (`ID`, `user`, `game`, `score`, `song`, `notestreak`, `notehit`) VALUES
(1, '$user', 1, 1, 1, 1, 1),
(2, '', 2, 0, 0, 22, 0),
(3, '', 2, 0, 0, 22, 0),
(4, '', 0, 11, 0, 0, 0),
(5, '', 0, 0, 0, 22, 0),
(6, 'Jargon', 1, 2442, 2, 99, 245),
(7, 'splosion man', 3, 0, 4, 0, 42);

-- --------------------------------------------------------

--
-- Table structure for table `score_songs`
--

CREATE TABLE IF NOT EXISTS `score_songs` (
  `song` varchar(255) NOT NULL,
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `game` int(11) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;

--
-- Dumping data for table `score_songs`
--

INSERT INTO `score_songs` (`song`, `ID`, `game`) VALUES
('cddf', 1, 2),
('My guitar is a hero', 2, 1),
('My fret is on fire', 3, 2),
('You mother is on fire.', 4, 3),
('You are somewhat agravating.', 5, 3);

Then I need it put in to php. Because I have no idea how.

 

Thanks,

 

Jragon.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.