Query: select " " from tablename



IBM's flagship relational database management system

Query: select " " from tablename

Postby bodhi » Wed Aug 08, 2007 12:38 pm

select " " from tablename where condition

what data will fetch by above mention qurey
bodhi
 
Posts: 52
Joined: Mon Jul 30, 2007 5:01 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Query: select " " from tablename

Postby dick scherrer » Thu Aug 09, 2007 7:44 am

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.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Query: select " " from tablename

Postby bodhi » Thu Aug 09, 2007 1:22 pm

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....
bodhi
 
Posts: 52
Joined: Mon Jul 30, 2007 5:01 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Query: select " " from tablename

Postby dick scherrer » Thu Aug 09, 2007 9:08 pm

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)
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times


Return to DB2

 


  • Related topics
    Replies
    Views
    Last post