sarsarahman
sarsarahman

Reputation: 1088

How to use like and in together?

How to use like and in together ?

SELECT a FROM A WHERE a LIKE (SELECT b FROM B WHERE c='india');

where column a and b are not equal but b only contains first three digits of a as shown below a=145xxxxxx; b=145;

any clue? how to achieve it?

Upvotes: 0

Views: 724

Answers (2)

juergen d
juergen d

Reputation: 204746

SELECT A.a 
FROM A 
inner join B on A.a like concat(B.b,'%')
             and B.c = 'india'

Upvotes: 1

ypercubeᵀᴹ
ypercubeᵀᴹ

Reputation: 115520

SELECT a FROM A 
WHERE EXISTS (SELECT 1 FROM B WHERE c='india' AND A.a LIKE CONCAT(B.b,'%') );

Upvotes: 0

Related Questions