Re: How to use Logic in View Statment?

2005-12-05 Thread Scott Klarenbach
As an update to my earlier question, is it possible to have logic in select statements including the join? ie, select IF(CHAR_LENGTH(broker)0,broker,vendor) as company from table 1 IF(CHAR_LENGTH(broker)0,INNER JOIN tblBroker,INNER JOIN tblVendor) Thanks. On 11/28/05, [EMAIL PROTECTED]

Re: How to use Logic in View Statment?

2005-12-05 Thread SGreen
Yes, but not quite as you imagined doing it. SELECT tbl1.*, coalesce(broker, vendor) as company from table1 tbl1 LEFT JOIN tblBroker b on tbl1.broker_id = b.id LEFT JOIN tblVendor v ON tbl1.vendor_id = v.id; The left joins indicates that the tables on right side of the join

How to use Logic in View Statment?

2005-11-28 Thread Scott Klarenbach
I'd like to do the following in my view select fieldOne, fieldTwo, if(fieldThree.length0) then fieldThree as Company else fieldFour as Company from table; I realize this syntax isn't correct and length doesn't exists, but is this possible? I've seen it done in SQLServer, but can't

Re: How to use Logic in View Statment?

2005-11-28 Thread SGreen
Scott Klarenbach [EMAIL PROTECTED] wrote on 11/28/2005 01:58:22 PM: I'd like to do the following in my view select fieldOne, fieldTwo, if(fieldThree.length0) then fieldThree as Company else fieldFour as Company from table; I realize this syntax isn't correct and length

Re: How to use Logic in View Statment?

2005-11-28 Thread Peter Brawley
Scott select fieldOne, fieldTwo, if(fieldThree.length0) then fieldThree as Company else fieldFour as Company from table; SELECT fieldOne, fieldTwo, IF( LENGTH( fieldthree ) 0, fieldthree, fieldFour ) AS Company FROM table; PB - Scott Klarenbach wrote: I'd like to do the

Re: How to use Logic in View Statment?

2005-11-28 Thread Cory @ SkyVantage
I have a similar question. How do you test if the field in question isn't NULL or '' (empty string)? Is the LENGTH a good test or is there a better way? [EMAIL PROTECTED] wrote: LENGTH does exist (as a function): http://dev.mysql.com/doc/refman/5.0/en/string-functions.html and here is

Re: How to use Logic in View Statment?

2005-11-28 Thread Martijn Tonies
I have a similar question. How do you test if the field in question isn't NULL or '' (empty string)? Is the LENGTH a good test or is there a better way? WHERE myfield IS NOT NULL -- Martijn Tonies Database Workbench - tool for InterBase, Firebird, MySQL, Oracle MS SQL Server Upscene

Re: How to use Logic in View Statment?

2005-11-28 Thread SGreen
Cory @ SkyVantage [EMAIL PROTECTED] wrote on 11/28/2005 02:38:50 PM: I have a similar question. How do you test if the field in question isn't NULL or '' (empty string)? Is the LENGTH a good test or is there a better way? [EMAIL PROTECTED] wrote: LENGTH does exist (as a

RE: How to use Logic in View Statment?

2005-11-28 Thread Gelu Gogancea
PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, 28 November, 2005 10:09 PM To: Cory @ SkyVantage Cc: My SQL Subject: Re: How to use Logic in View Statment? Cory @ SkyVantage [EMAIL PROTECTED] wrote on 11/28/2005 02:38:50 PM: I have a similar question. How do you test if the field in question