Click to See Complete Forum and Search --> : Select SQL
Nolik
Mar 22nd, 2000, 09:22 PM
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.
bsmith
Mar 22nd, 2000, 10:41 PM
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.
Clunietp
Mar 22nd, 2000, 11:56 PM
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"
JHausmann
Mar 23rd, 2000, 01:26 AM
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.
Nolik
Mar 23rd, 2000, 06:19 AM
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.
Clunietp
Mar 23rd, 2000, 09:25 AM
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"
JHausmann
Mar 24th, 2000, 12:39 AM
Suppose I should've said Clunietp. :)
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.