Hellol,
First of all…
Can’t change the tables structure.
I want to list, for a given .tld the registration prices per year on the cases where they are set. (this means, on the cases where the price (on a given currency) on a given period (Annual, biannual etc…) is greater then 0).
On one table tblpricing I have the prices of a given period:
CREATE TABLE `tblpricing` (
`id` int(10) NOT NULL auto_increment,
`type` enum('product','addon',
'configoptions','domainregister',
'domaintransfer','domainrenew',
'domainaddons') NOT NULL,
`relid` int(10) NOT NULL,
`currency` int(10) NOT NULL,
`msetupfee` decimal(10,2) NOT NULL,
`qsetupfee` decimal(10,2) NOT NULL,
`ssetupfee` decimal(10,2) NOT NULL,
`asetupfee` decimal(10,2) NOT NULL,
`bsetupfee` decimal(10,2) NOT NULL,
*PRIMARY KEY *(`id`)
) ENGINE=MyISAM AUTO_INCREMENT=349 DEFAULT CHARSET=latin1
I’ve found that (don’t ask me why):
msetupfee stores the price for 1 year;
qsetupfee stores the price for 2 years;
ssetupfee stores the price for 3 years;
asetupfee stores the price for 4 years;
bsetupfee stores the price for 5 years;
I’ve also found that the type(enum) is set to ‘domainregister’ - since we want the registration prices listed.
Lastly, found that relid corresponds to the ID of the next table:
On this other table, we have the .tld list:
CREATE TABLE `tbldomainpricing` (
`id` int(10) NOT NULL auto_increment,
`extension` text NOT NULL,
PRIMARY KEY (`id`),
KEY `extension_registrationperiod` (`extension`(32)),
KEY `order` (`order`)
) ENGINE=MyISAM AUTO_INCREMENT=12 DEFAULT CHARSET=latin1
The extension column contains the .tld values (.com, .net, .org….);
According to all this, I was trying to follow this path:
SELECT t1.extension,
t2.msetupfee AS anual,
t2.qsetupfee AS bienal,
t2.ssetupfee AS trienal,
t2.asetupfee AS quadrienal,
t2.bsetupfee AS quinquenal
FROM `tbldomainpricing` AS t1
INNER JOIN `tblpricing` AS t2
ON t1.id = t2.relid
WHERE t2.type = 'domainregister'
AND t2.currency = 1
AND t1.extension = '.com'
With this query I can list all the columns that I need listed as intended, however, if a column let’s say “msetupfee” or “qsetupfee” has the value of 0, I wish NOT to list it.
How can this be achieved?
Generally speaking:
“If a given row on a given column as a certain value, don’t list that column.” ?
Thanks in advance,
Márcio