Page 1 of 1

Query: select " " from tablename

PostPosted: Wed Aug 08, 2007 12:38 pm
by bodhi
select " " from tablename where condition

what data will fetch by above mention qurey

Re: Query: select " " from tablename

PostPosted: Thu Aug 09, 2007 7:44 am
by dick scherrer
Hello,

There is no reason other than"playing around" to write such a query.

How many rows will match the "where"?

What you have asked the system to do is to "return" one space for each row matching the "where".

Depending on where the select was issued, you may also get an sql error.

Re: Query: select " " from tablename

PostPosted: Thu Aug 09, 2007 1:22 pm
by bodhi
SELECT GP.NO_PART_BASE,
GP.NO_PART_PREFIX,
GP.NO_PART_SUFFIX,
GP.NO_PART_CONTROL,
GP.DS_PART,
GP.CD_PART_STATUS,
GP.CD_PART_TYPE
FROM GMP_GEN_PART GP
WHERE GP.CD_PLANT = :WS-PLANT-HOLD
AND GP.NO_PART_BASE
|| GP.NO_PART_PREFIX
|| GP.NO_PART_SUFFIX
|| GP.NO_PART_CONTROL > :WS-CON-GP-PART
AND GP.CD_PART_STATUS NOT IN (:LIT-O, :LIT-D)
AND GP.CD_PART_TYPE IN (:LIT-EI, :LIT-CS)
AND GP.CD_DECOST_IND IN (:LIT-SP, :LIT-R)
AND EXISTS
(SELECT " "
FROM GMP_CSTBY_ACCT CB

WHERE CB.CD_PLANT = :WS-PLANT-HOLD
AND GP.CD_PLANT = CB.CD_PLANT
AND GP.NO_PART_BASE = CB.NO_PART_BASE
AND GP.NO_PART_PREFIX = CB.NO_PART_PREFIX
AND GP.NO_PART_SUFFIX = CB.NO_PART_SUFFIX
AND GP.NO_PART_CONTROL = CB.NO_PART_CONTROL
AND CB.YY_YEAR = :GMPC005-YY-YEAR
AND CB.CD_COST_TYPE = :LIT-A
AND CB.CD_RECORD_TYPE
IN (:LIT-1,:LIT-2,:LIT-6,:LIT-9)
AND CB.DT_EFFECTIVE <= :WS-MONTH-END-CURR
AND CB.DT_EFFECTIVE > :WS-MONTH-END-PRIOR)

i am asking about the bolded part....

Re: Query: select " " from tablename

PostPosted: Thu Aug 09, 2007 9:08 pm
by dick scherrer
Ahhh - it makes more sense when seen in context. . . .

If you want to see if any exist or how many rows match your "where" conditions, you might try
select count(*) from  GMP_CSTBY_ACCT CB
having count(*) > 0
where. . . (all of your predicates)