I have a table on a remote server that stores version numbers for our client side software. I use SOAP to handle requests. The client software sends a version number and I need to use SQL to find the next version numbers.
Here’s the SQL that I use. I’m having a bit of a bad brain day, and I know this isn’t correct but I can’t seem to figure out what I need to do.
The create table code:
CREATE TABLE IF NOT EXISTS `sqlUpdateVersions` (
`primary_key` int(11) NOT NULL AUTO_INCREMENT,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`comment` text NOT NULL,
`majorVS` tinyint(4) NOT NULL,
`minorVS` tinyint(4) NOT NULL,
`revisionVS` tinyint(4) NOT NULL,
`buildVS` tinyint(4) NOT NULL,
`filePK` int(11) NOT NULL,
`customDBJarPK` int(11) DEFAULT NULL,
PRIMARY KEY (`primary_key`),
KEY `filePK` (`filePK`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;
This is the SQL query to find a version #. I dumped in this version 1.1.0.0
select b.majorVS, b.minorVS,b.revisionVS, b.buildVS
from sqlUpdateVersions b where
b.majorVS>=1 AND b.minorVS >=1 AND b.revisionVS>=0 AND b.buildVS>=10
ORDER BY b.majorVS,b.minorVS,b.revisionVS, b.buildVS
Now clearly I can tell this SQL is problematic. But how would I structure one that would return the next values, say 1.2.0.0 or 1.1.1.0
Thanks.
Here is a brute force approach:
You can also convert the versions to a bigint and do the comparison directly: