Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 选择一个表的数据,就像选择其他表的数据一样_Php_Mysql - Fatal编程技术网

Php 选择一个表的数据,就像选择其他表的数据一样

Php 选择一个表的数据,就像选择其他表的数据一样,php,mysql,Php,Mysql,我有两个表,例如atab和btab使用mysql查询: 请帮我做以下说明(我是mysql的新手): 从atab中选择*,其中列1类似于(表中的列2); 由于select查询(第二个表)不是指定给单行,而是指定给整行,所以显示数据(可能)需要很长时间,对吗? 如何优化它?可能吗?尝试此查询 SELECT * FROM atab WHERE column1 LIKE (select column2 from btab); 尝试删除此查询 SELECT * FROM atab WHERE co

我有两个表,例如
atab
btab
使用mysql查询:
请帮我做以下说明(我是mysql的新手):

从atab中选择*,其中列1类似于
表中的列2
);

由于select查询(第二个表)不是指定给单行,而是指定给整行,所以显示数据(可能)需要很长时间,对吗? 如何优化它?可能吗?

尝试此查询

SELECT * FROM atab WHERE column1 LIKE (select column2 from btab); 
尝试删除此查询

SELECT * FROM atab WHERE column1 LIKE (select column2 from btab); 

使用
存在

select *
from atab a
where exists (
        select 1
        from btab b
        where a.column1 like concat('%',b.column2,'%')
        );

使用
存在

select *
from atab a
where exists (
        select 1
        from btab b
        where a.column1 like concat('%',b.column2,'%')
        );

两个表之间是否存在任何关系?不确定,因为它类似于查看第二个表的值是否与第一个表中的值相似。两个表之间是否存在任何关系?不确定,因为它类似于查看第二个表的值是否与第一个表中的值相似。它起作用,但显示数据大约需要12秒。如何使它更快?那是因为like不能使用索引。您应该寻找其他选项-有用的链接。那么,这是行内的一个价值问题。谢谢^ ^它可以工作,但显示数据大约需要12秒。如何使它更快?那是因为like不能使用索引。您应该寻找其他选项-有用的链接。那么,这是行内的一个价值问题。谢谢^_^