Re: select only values >0

2005-02-17 Thread Mike Rains
> Dear All, from a single row of a table, I have to select only the column,
> which have a value larger '0' into an outfile.
> How can I manage it with 'select'? Thanks, Jan

SELECT CASE can do that sort of thing for you. Here's a simplistic example:

CREATE TABLE `test`
(
`i1` int, 
`i2` int, 
`i3` int
);
INSERT INTO `test` 
(`i2`)
VALUES 
(2);

SELECT
CASE
WHEN  `i1` > 0 THEN
'Field 1'
WHEN `i2` > 0 THEN
'Field 2'
WHEN `i3` > 0 THEN
'Field 3'
ELSE
'No match'
END
AS `iMatch`
FROM `test`;

+-+
| iMatch  |
+-+
| Field 2 |
+-+

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: select only values >0

2005-02-17 Thread Michael Dykman
You can't conditionally select columns with a mere select statement..  
In whatever langauge you are using to process (perl, Java, whatever) you
are going to have to select the entire row and use locig to pick out the
columns that you want

 - michael dykman

On Thu, 2005-02-17 at 11:44, Jan Bartholdy wrote:
> Dear All, from a single row of a table, I have to select only the column,
> which have a value larger '0' into an outfile.
> How can I manage it with 'select'? Thanks, Jan
> 
> 
> 
> Virus checked by G DATA AntiVirusKit
> Version: AVK 15.0.2975 from 09.02.2005
-- 
 - michael dykman
 - [EMAIL PROTECTED]


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



select only values >0

2005-02-17 Thread Jan Bartholdy
Dear All, from a single row of a table, I have to select only the column,
which have a value larger '0' into an outfile.
How can I manage it with 'select'? Thanks, Jan



Virus checked by G DATA AntiVirusKit
Version: AVK 15.0.2975 from 09.02.2005


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]