CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> General/Other

 Need SQL help :)

Print topic Send  topic

Author Message
Gena

Posts: 591
Posted: 02/24/2009, 11:17 AM

I have some SELECT, as WHERE I have something like this

select ... where .... and prof like '%" . $prof . "%'

it works if there is some info in "prof" field. If there is NO info - it doesn't work (sure it works, but SELECT returns nothing).

But I need act like:

if there is info in prof - then check this field with LIKE
if ther is no info - do not check ever this field

i'm a bit confused. please advise.


_________________
Gena
View profile  Send private message
dataobjx


Posts: 181
Posted: 02/24/2009, 1:56 PM

The easiest way to do this is to create a view.

In the view you would use sql similar to...

select ... where prof is not null

Thus the view never returns records where prof is null

Now, you can use your original select statement against the view rather than the table.
_________________
www.DataObjx.net
www.mydigitalapps.com
View profile  Send private message
Gena

Posts: 591
Posted: 02/24/2009, 2:15 PM

dataobjx, thanks

I have made some modification and it works now:

and (prof like '%" . $prof . "%' or prof is NULL)
_________________
Gena
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.