0

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?

4

2 回答 2

1
SELECT A.a 
FROM A 
inner join B on A.a like concat(B.b,'%')
             and B.c = 'india'
于 2013-09-06T12:29:39.663 回答
0
SELECT a FROM A 
WHERE EXISTS (SELECT 1 FROM B WHERE c='india' AND A.a LIKE CONCAT(B.b,'%') );
于 2013-09-06T13:09:04.160 回答