1

I have a query like this :

select * from employee where (employee_id in (SELECT DISTINCT 
SubTable.blockid 
        FROM 
                  broad.territory_block 
                  BlockSubTable 
                                         WHERE  ( ( 
                  BlockSubTable.id IN ( 398 ) ))))

Now here my employee_id is of 10 digits and the output of the subquery would be of 13 digits. I tried using left('',10) for matching the subquery output but getting error for misplaced left function. Can someone please help me how should I use left function to match the result. I need to match the employee_id with the subquery output

P.S : This is not the actual query, created for explaining the problem

3
  • Sample data and desired results would really help. I'm totally lost why you wold compare something called employeeid to something called blockid. Commented Aug 13, 2020 at 14:39
  • What are the data types of those columns? Commented Aug 13, 2020 at 14:41
  • 1
    did u tried SELECT DISTINCT LEFT(SubTable.blockid , 10) FROM ... Commented Aug 13, 2020 at 14:42

1 Answer 1

3

Just apply it to the column:

select * 
from employee 
where employee_id in (SELECT left(blockid, 13)
                      FROM  BlockSubTable 
                      WHERE  BlockSubTable.id IN ( 398 ) )
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you so much for your quick help.!! :D
@Developer52 you should accept the answer if it resolves your problem

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.