From: "Frank Keessen" <[EMAIL PROTECTED]>

> I hope you can help me with this:
>
> I have a tabel in my database like this
>
> TEST
>
> fieldname    Value's
>
> testid          1
> testf1           3
> testf2           4
> testf3           0
> testf4           2
> testf5           0
>
> (so this is one record!)

Those are columns, right? Anytime you have columns named like that it means
you have a horrible database design.You're going to be better of pulling
this into PHP and finding the min() number.

Here's one way to do it in SQL, but you see how complex it is with just
three columns:

select case
when a>0 and b>0 and c>0 then least(a,b,c)
when a>0 and b>0 then least(a,b)
when a>0 and c>0 then least(a,c)
when b>0 and c>0 then least(b,c)
when a>0 then a
when b>0 then b
when c>0 then c
end from test;

---John Holmes...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to