DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2

Thread: Select in SQL

  1. #1
    Arnold Guest

    Select in SQL


    Hi,

    I am trying to select a field with two different conditions in one SQL statement.

    Some thing like this(dose not work)

    select
    acclst.acc_no as sacc_no, acclst.acc_no as lacc_no
    from
    acclst acclst
    where
    acclst.acc_type in(select acclst.acc_type from acclst where acclst.acc_type
    = "L")and
    acclst.acc_type in(select acclst.acc_type from acclst where acclst.acc_type
    = "S")

    If any one has suggestions please reply.

    Thank you.

  2. #2
    Tahir Guest

    Re: Select in SQL


    Hi,

    If your tables are same like in your example then its very easy as you can
    write like
    where
    acclst.acc_type in(select acclst.acc_type from acclst where acclst.acc_type
    >= "L" and/or acclst.acc_type >= "W")


    But, if your condition tables are different then perhaps you can write something
    like

    where
    acclst.acc_type in(select acclst.acc_type from acclst where acclst.acc_type
    >= "L" UNION

    select acclst.acc_type from acclst where acclst.acc_type >= "W")

    Hope this helps.




    "Arnold" <nolik1@excite.com> wrote:
    >
    >Hi,
    >
    >I am trying to select a field with two different conditions in one SQL statement.
    >
    >Some thing like this(dose not work)
    >
    >select
    >acclst.acc_no as sacc_no, acclst.acc_no as lacc_no
    >from
    >acclst acclst
    >where
    >acclst.acc_type in(select acclst.acc_type from acclst where acclst.acc_type
    >= "L")and
    >acclst.acc_type in(select acclst.acc_type from acclst where acclst.acc_type
    >= "S")
    >
    >If any one has suggestions please reply.
    >
    >Thank you.



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links