如何一起使用?

时间:2013-09-06 12:26:22

标签: mysql sql select sql-like

如何一起使用?

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

其中a和b列不相等但b仅包含a的前三位数,如下所示 A = 145xxxxxx; B = 145;

任何线索?如何实现呢?

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:0)

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