Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
Nested IF within a Select statement
Old 07-18-2006, 09:28 AM Nested IF within a Select statement
Junior Talker

Posts: 2
Trades: 0
Hi,

I need to bring back a row of results, all the fields are straight forward returns, however one field needs to be dynamic, I need to check the field, if something is there, return the value, however if nothing is there, to display a different value

Something like this

select field1
, field2
, (IF field3 IS NOT NULL field3 else 'No value') AS TheResult
from Tbl1

Anytime I try it always errors saying error with IF.

Any ideas how to do this?

Ad
DaDon is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-21-2006, 10:22 PM Re: Nested IF within a Select statement
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,898
Name: Keith Marshall
Location: Connecticut
Trades: 0
I say just return the field values as normal, and do the conditional evaluation in the script to diplay field value or else value. As in php, you could evaluate the row field like:

echo ($row['field3'] != "") ? $row['field3'] : 'No Value';
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 07-24-2006, 07:50 AM Re: Nested IF within a Select statement
Junior Talker

Posts: 2
Trades: 0
Thanks!

I was trying to get all the logic for table manipulation in the stored proc to keep front end simple though, I have to display it in a few different ways (Excel, Access, Web) and dont want to put db logic in the front ends.

DaDon
DaDon is offline
Reply With Quote
View Public Profile
 
Old 07-29-2006, 03:47 PM Re: Nested IF within a Select statement
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
What database are you using ??
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-01-2006, 10:43 AM Re: Nested IF within a Select statement
saadatshah's Avatar
Extreme Talker

Posts: 215
Name: Syed Saadat Ali
Location: Lahore, Pakistan
Trades: 0
Kindly specify the Database you are using as your backend.
__________________
- -- --- ---- ----- ------ ------- ---------------
If you have knowledge, let others light their candles in it.
saadatshah is offline
Reply With Quote
View Public Profile Visit saadatshah's homepage!
 
Reply     « Reply to Nested IF within a Select statement
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.27142 seconds with 12 queries