Hi,
I need to write a query to find whether a particular record exists or not in a table. Basically I want the query to return a single value if the record is found.
Below are the possible solutions
SELECT 1
FROM MSG_STATUS
WHERE MSST_MSG_CTRL = 'H50344'
FETCH FIRST 1 ROW ONLY
SELECT distinct 1
FROM MSG_STATUS
WHERE MSST_MSG_CTRL = 'H50344'
SELECT COUNT(*)
FROM MSG_STATUS
WHERE MSST_MSG_CTRL = 'H50344'
SELECT 1
FROM SYSIBM.SYSDUMMY1 A
WHERE EXISTS (
SELECT 1 FROM
FROM MSG_STATUS
WHERE MSST_MSG_CTRL= 'H50344'
AND A.IBMREQD = A.IBMREQD
)
Is there any other way I can know whether the record is there or not .. performance is really a issue has the table contains records in lakhs or more
Pls let me know…
Regards
dilip