Suppose I have a table abc
with columns p_id
,u_id
, and comments
. I want to fetch the data from this table only if there are multiple rows for a particular p_id
value (there is a single row of "junk" data in the table for every p_id
that I want to ignore). How can I structure my query so that I can determine whether there are multiple rows for a p_id
without fetching the data from the cursor.
Currently, my code looks something like this
Declare
Cursor pqr is
Select p_id,u_id,comments from abc where p_id=123;
Begin
--I want to ignore the results if this query returns 0 or 1 row.
--I only want to process the data if this query returns multiple rows
End;