# Board index » delphi » IB Exists

## IB Exists

2007-01-10 12:09:52 AM
delphi5
IB 6,02
MCODE SCODE NUM
AAA BBB 1
AAA CCC 1
BBB DDD 2
BBB EEE 1
The only value I know is MCODE's value, which is AAA ,
how can i get BBB's SCODE s
the result should be
BBB DDD 2
BBB EEE 1

## Re:IB Exists

Serra writes:
##### Quote
IB 6,02

MCODE SCODE NUM
AAA BBB 1
AAA CCC 1
BBB DDD 2
BBB EEE 1

The only value I know is MCODE's value, which is AAA ,
how can i get BBB's SCODE s

the result should be
BBB DDD 2
BBB EEE 1
If these are the only two codes in MCODE then you simply need to query for
MCODE <>'AAA', but I'd assume there are other codes too, so that won't
work - but then what you are asking for also doesn't make sense - you need
to explain more what you are trying to do - you cannot look for a specific
value if you do not know that value.
--
Wayne Niddery - Winwright, Inc (www.winwright.ca)
"Bandwagons are like streetcars, there'll be another along in a few
minutes."

## Re:IB Exists

Thank you Wayne,
MyTable ( I put the stars (*) extra for your attention )
MCODE SCODE NUM
AAA BBB* 1
AAA CCC 1
BBB* DDD 2
BBB* EEE 1
SELECT * FROM MYTABLE WHERE MCODE='AAA'
Result=
MCODE SCODE NUM
AAA BBB 1
AAA CCC 1
Now i need if BBB and/or CCC exists in MCODE also ?
which is yes for BBB in above sample table
(BBB has 2 records )
Requested result should be
BBB DDD 2
BBB EEE 1
##### Quote
>The only value I know is MCODE's value, which is AAA ,
>how can i get BBB's SCODE s
>
>the result should be
>BBB DDD 2
>BBB EEE 1

If these are the only two codes in MCODE then you simply need to query for
MCODE <>'AAA', but I'd assume there are other codes too, so that
won't work - but then what you are asking for also doesn't make sense -
you need to explain more what you are trying to do - you cannot look for a
specific value if you do not know that value.

--
Wayne Niddery - Winwright, Inc (www.winwright.ca)
"Bandwagons are like streetcars, there'll be another along in a few
minutes."

## Re:IB Exists

select * from <YouTable>
where MCODE in (select SCODE from <YourTable>where MCODE='AAA')
--
Best regards.
Pavel Kutakov
Interbase Development Studio - complete Interbase development solution
www.sqlly.com

## Re:IB Exists

Exactly. Thank you Pavel
##### Quote
select * from <YouTable>
where MCODE in (select SCODE from <YourTable>where MCODE='AAA')
Best regards.
Pavel Kutakov
Interbase Development Studio - complete Interbase development solution
www.sqlly.com