Please help me with below query , I want to check if string is starts with 'G' or 'F' in where condition along with existing condition. here is the query
first query :-
SELECT Top 1 LC_ID,ISNULL(LC_UD,0) as Record from CONTRACT where LC_ID ='F01'
output
F01 | 1 ( if available) else no record will be return.
second query:
IF LC_ID starts with 'F%' or 'G%'
How i can integrate both the query into one so that if there is no record available for 'F01' value, it will check if LC_ID starts with F & G then return
output
F04 | 1
DECLARE @RC INT = 0;
SELECT Top 1 LC_ID,ISNULL(LC_UD,0) as Record from CONTRACT where LC_ID ='F01';
SET @RC = @@ROWCOUNT;
IF @RC > 0
BEGIN
-- Second select
END
My logic works exactly the way I intended and the way I thought you wanted it, when I read your initial post.
Obviously I didn't understand what it is you're trying to accomplish, so to get to a solution you can use, the best thing would be that you provide sample data and expected output. Please make at least two scenarios - one where your first query return records and one where it doesn't.