arenaninja Posted March 14, 2012 Share Posted March 14, 2012 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) Quote Link to comment Share on other sites More sharing options...
fenway Posted March 17, 2012 Share Posted March 17, 2012 If you read the posting rules, you'll notice that we'll need much more information to help you. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.