Results 1 to 7 of 7

Thread: Select SQL

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    2
    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
    Lively Member
    Join Date
    Jan 2000
    Location
    Springfield, IL
    Posts
    124
    I dont't think you can do what you are trying to do. You can create a stored procedure to return a recordset based on the acc_type. The execute the stored procedure twice once when acc_type = "L" and once when acc_type = "S". Or you can select acc_no and acc_type and loop through the recordset and process on the acc_type. It depends on what you are trying to do with the select.

  3. #3
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    Why don't you do this?

    select
    acclst.acc_no as sacc_no, acclst.acc_no as lacc_no
    from
    acclst acclst
    where
    acclst.acc_type = "L" OR
    acclst.acc_type = "S"


  4. #4
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    Use Tom's SQL. Yours doesn't work because your query expects one field to have two values/record. acclst.acc_type cannot be "L" and "S", at the same time.

  5. #5

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    2

    what is Tom's SQL?


    Use Tom's SQL. Yours doesn't work because your query expects one field to have two values/record. acclst.acc_type cannot be "L" and "S", at the same time.

  6. #6
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    Sorry! I am TOM. This is my code.


    Why don't you do this?

    select
    acclst.acc_no as sacc_no, acclst.acc_no as lacc_no
    from
    acclst acclst
    where
    acclst.acc_type = "L" OR
    acclst.acc_type = "S"



  7. #7
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    Suppose I should've said Clunietp.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width