Jump to content

Help with this select query


arenaninja

Recommended Posts

I'm trying to get a fee schedule table to work. The fee schedule table itself:

CREATE TABLE `feeschedule` (
  `pkFeeSchdID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `fkEquipID` int(10) unsigned NOT NULL,
  `fkInstTypeID` int(10) unsigned NOT NULL,
  `rate` decimal(5,2) DEFAULT NULL,
  PRIMARY KEY (`pkFeeSchdID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1

It stores the equipment, the institution type, and a rate for that institution type.

 

The table is currently empty. However, I'm trying to query this table to also retrieve the associated data from fkEquipID and fkInstTypeID, with just the 'rate' values coming as 'NULL' (the reason why is because a new instTypeID or EquipID could be inserted into the db at any time, and in that case I still need to have one row per instTypeID). I've attached an image which is sample of what I need to come out. The code below is what I've tried. I've alternated between Right joins and left joins but I'm really just shooting in the dark here. Any suggestions would be welcome.

SELECT feeschedule.*, equip.equipid,equip.name,equip.name_short, insttypes.* FROM feeschedule RIGHT JOIN equip on (feeschedule.fkEquipID=equip.equipid) RIGHT JOIN insttypes on (feeschedule.fkInstTypeID=insttypes.instTypeID)

post-128265-13482403314864_thumb.png

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.