Application Development and Automation 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: 
Read only

Doubt in select query

Former Member
0 Likes
1,022

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
Read only

Former Member
0 Likes
993

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
Read only

Former Member
0 Likes
993

Hi,

Don't take that field in where condition.

Read only

Former Member
0 Likes
993

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

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

Read only

Former Member
0 Likes
993

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.

Read only

former_member195383
Active Contributor
0 Likes
993

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

Read only

Former Member
0 Likes
994

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.

Read only

Former Member
0 Likes
993

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

Read only

Former Member
0 Likes
993

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.