Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/283.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.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 搜索引擎MySQL的动态过滤器_Php_Mysql - Fatal编程技术网

Php 搜索引擎MySQL的动态过滤器

Php 搜索引擎MySQL的动态过滤器,php,mysql,Php,Mysql,现在,如何从表2中选择*,其中ID在select AUCTION中,ID在表1中,value_type=726,value='a',value_type=270,value='b' 所以查询效果应该是ID为1和2的拍卖 如何通过一个SQL查询或在PHP中完成 附言 此查询正在运行: 从表中选择ID,其中“a”、“b”、“c”组中的值按COUNTID>=3的ID排列 但这会暂停服务器: 从表中选择*1=1,从表中选择id,从表中选择id,其中“a”、“b”、“c”组中的值由COUNTID>=3的i

现在,如何从表2中选择*,其中ID在select AUCTION中,ID在表1中,value_type=726,value='a',value_type=270,value='b'

所以查询效果应该是ID为1和2的拍卖

如何通过一个SQL查询或在PHP中完成

附言

此查询正在运行: 从表中选择ID,其中“a”、“b”、“c”组中的值按COUNTID>=3的ID排列

但这会暂停服务器: 从表中选择*1=1,从表中选择id,从表中选择id,其中“a”、“b”、“c”组中的值由COUNTID>=3的id表示,我建议存在该值。两次:

为了提高性能,您需要在Table1Action\u id、value\u type和value上建立索引

TABLE1 (Values)
ID|AUCTION_ID|VALUE_TYPE|VALUE
1|1|726|a
2|1|270|b
3|2|726|a
4|2|270|b
5|3|726|a
6|3|270|b
7|4|983|z
8|4|822|a

TABLE2 (Auctions)
ID|TITLE|DSC|PRICE
1|xxx|xxxxxxxxx|xxx
2|xxx|xxxxxxxxx|xxx
3|xxx|xxxxxxxxx|xxx
4|xxx|xxxxxxxxx|xxx
select t2.*
from TABLE2 t2
where exists (select 1
              from Table1 t1
              where t2.id = t1.AUCTION_ID and t1.value_type = 726 and t1.value = 'a'
             ) and
      exists (select 1
              from Table1 t1
              where t2.id = t1.AUCTION_ID and t1.value_type = 270 and t1.value = 'b'
             );