?
Solved

SQL ilas_prov_location field  not "TS%" and not "JP%"

Posted on 2014-08-14
2
Medium Priority
?
126 Views
Last Modified: 2014-08-20
(IsTSL ? string.Empty : "Where ilas_prov_location LIKE 'TS%'") +
                (IsJPN ? string.Empty : "Where ilas_prov_location LIKE 'JP%'") +
                (IsJPN || IsTSL ? string.Empty : "What Should I not") +
Untitled.png
0
Comment
Question by:fsze88
2 Comments
 
LVL 49

Expert Comment

by:PortletPaul
ID: 40259988
I do not understand the question. If the query below does not meet your expectations please explain in some more detail what you are asking for.

SELECT
      *
FROM prod_type
WHERE ilas_prov_location NOT LIKE 'TS%'
      AND ilas_prov_location NOT LIKE 'JP%'

Open in new window

0
 
LVL 36

Accepted Solution

by:
ste5an earned 2000 total points
ID: 40260069
I don't understand your code either.

namespace ConsoleApplication2
{
    using System;

    class Program
    {
        static void Main(string[] args)
        {
            bool IsTSL ;
            bool IsJPN ;
            string result;
            
            IsTSL = true;
            IsJPN = true;
            result =
                (IsTSL ? string.Empty : "Where ilas_prov_location LIKE 'TS%'") +
                (IsJPN ? string.Empty : "Where ilas_prov_location LIKE 'JP%'") +
                (IsJPN || IsTSL ? string.Empty : "What Should I not");
            Console.WriteLine("IsTSL={0}, IsJPN={1} \t\t=> |{2}|", IsTSL, IsJPN, result);

            IsTSL = false;
            IsJPN = true;
            result =
                (IsTSL ? string.Empty : "Where ilas_prov_location LIKE 'TS%'") +
                (IsJPN ? string.Empty : "Where ilas_prov_location LIKE 'JP%'") +
                (IsJPN || IsTSL ? string.Empty : "What Should I not");
            Console.WriteLine("IsTSL={0}, IsJPN={1} \t=> |{2}|", IsTSL, IsJPN, result);

            IsTSL = true;
            IsJPN = false;
            result =
                (IsTSL ? string.Empty : "Where ilas_prov_location LIKE 'TS%'") +
                (IsJPN ? string.Empty : "Where ilas_prov_location LIKE 'JP%'") +
                (IsJPN || IsTSL ? string.Empty : "What Should I not");
            Console.WriteLine("IsTSL={0}, IsJPN={1} \t=> |{2}|", IsTSL, IsJPN, result);

            IsTSL = false;
            IsJPN = false;
            result =
                (IsTSL ? string.Empty : "Where ilas_prov_location LIKE 'TS%'") +
                (IsJPN ? string.Empty : "Where ilas_prov_location LIKE 'JP%'") +
                (IsJPN || IsTSL ? string.Empty : "What Should I not");
            Console.WriteLine("IsTSL={0}, IsJPN={1} \t=> |{2}|", IsTSL, IsJPN, result);

            Console.ReadLine();
        }
    }
}

Open in new window


returns

Result
I guess you're trying to built a entire WHERE condition. E.g.

namespace ConsoleApplication2
{
    using System;

    class Program
    {
        static void Main(string[] args)
        {
            bool IsTSL;
            bool IsJPN;
            string result;

            IsTSL = true;
            IsJPN = true;
            result =
                (IsTSL ? string.Empty : "AND ilas_prov_location LIKE 'TS%'") +
                (IsJPN ? string.Empty : "AND ilas_prov_location LIKE 'JP%'");
            Console.WriteLine("IsTSL={0}, IsJPN={1} \t\t=> |{2}|", IsTSL, IsJPN,
                result.Equals(string.Empty) ? string.Empty : "WHERE " + result.Substring(4));

            IsTSL = false;
            IsJPN = true;
            result =
                (IsTSL ? string.Empty : "AND ilas_prov_location LIKE 'TS%'") +
                (IsJPN ? string.Empty : "AND ilas_prov_location LIKE 'JP%'");
            Console.WriteLine("IsTSL={0}, IsJPN={1} \t=> |{2}|", IsTSL, IsJPN,
                result.Equals(string.Empty) ? string.Empty : "WHERE " + result.Substring(4));

            IsTSL = true;
            IsJPN = false;
            result =
                (IsTSL ? string.Empty : "AND ilas_prov_location LIKE 'TS%'") +
                (IsJPN ? string.Empty : "AND ilas_prov_location LIKE 'JP%'");
            Console.WriteLine("IsTSL={0}, IsJPN={1} \t=> |{2}|", IsTSL, IsJPN,
                result.Equals(string.Empty) ? string.Empty : "WHERE " + result.Substring(4));

            IsTSL = false;
            IsJPN = false;
            result =
                (IsTSL ? string.Empty : "AND ilas_prov_location LIKE 'TS%'") +
                (IsJPN ? string.Empty : "AND ilas_prov_location LIKE 'JP%'");
            Console.WriteLine("IsTSL={0}, IsJPN={1} \t=> |{2}|", IsTSL, IsJPN,
                result.Equals(string.Empty) ? string.Empty : "WHERE " + result.Substring(4));

            Console.ReadLine();
        }
    }
}

Open in new window


This returns
Result
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question