Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Doubt in select query

Former Member
0 Kudos
204

hello friends , i have one simple doubt

tables:plpo,plfh.

select * from plpo

where plnty = 'N'

and plnNR = group_number "'CEWGRP'

and vornr = W_ASSIGN_PRT-OPERATION_NUMBER.

endselect.

select * from plfh where

plnty = 'N'

and plnnr = group_number

and plnkn = plpo-plnkn

and loekz = 'x'.

endselect.

for the last select query i want that query should take records with both loekz = 'x' and loekz ne 'x' ..so waht can i do without changing any field above loekz....might be something like

(where loekz id deletion indicator)

select * from plfh where

plnty = 'N'

and plnnr = group_number

and plnkn = plpo-plnkn

and loekz = 'x' or loekz ne 'x'...is something like this possible?means it shd take into consideration both records with x and without x.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
175

Hi,

You can write in 3 ways.

1.

select * from plfh where

plnty = 'N'

and plnnr = group_number

and plnkn = plpo-plnkn

and ( loekz = 'x' or loekz EQ '' ).

2. select * from plfh where

plnty = 'N'

and plnnr = group_number

and plnkn = plpo-plnkn

and loekz IN ( 'x' ,' ' ).

3.

select * from plfh where

plnty = 'N'

and plnnr = group_number

and plnkn = plpo-plnkn.

7 REPLIES 7

Former Member
0 Kudos
175

Hi,

Don't take that field in where condition.

Former Member
0 Kudos
175

Yes You can use that... but what is the necessity to include both with 'X' and ' '.

instead u can use loekx = 'X' or loekx = ' '.

Former Member
0 Kudos
175

Hello,

loekz is a deletion indicator. So it can have value 'X' or space.

In order to pick up records you can ignore loekz from select query.

Regards,

preeti.

former_member195383
Active Contributor
0 Kudos
175

Remove loekz from ur select query.So irrespective of loekz value,it ll select the data

select * from plfh where

plnty = 'N'

and plnnr = group_number

and plnkn = plpo-plnkn

.

will work....

Reward if useful.

Regards

Rudra

Former Member
0 Kudos
176

Hi,

You can write in 3 ways.

1.

select * from plfh where

plnty = 'N'

and plnnr = group_number

and plnkn = plpo-plnkn

and ( loekz = 'x' or loekz EQ '' ).

2. select * from plfh where

plnty = 'N'

and plnnr = group_number

and plnkn = plpo-plnkn

and loekz IN ( 'x' ,' ' ).

3.

select * from plfh where

plnty = 'N'

and plnnr = group_number

and plnkn = plpo-plnkn.

Former Member
0 Kudos
175

hi ,

Dont take that field in ur where condition if u want to have both the values x and space.

if there are some other values for that field other than X and space ,u should write

field ='X' or field = space in where clause.

pls reward if helpful.

regards,

Deepa

Former Member
0 Kudos
175

thanks a lot muralikrishna k.

it was a very nice answer by u which helped me to solve my problem.

and thank u all for replying to my thread.