Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.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_Sql - Fatal编程技术网

Php 在mysql中,如何使用子查询或内部查询在单个查询中组合两个查询

Php 在mysql中,如何使用子查询或内部查询在单个查询中组合两个查询,php,mysql,sql,Php,Mysql,Sql,如果我把你的要求弄对了,那就行了 select sub.sub_product_image_path, sub.sub_product_id from `portal_products(sub category)` sub , `portal_products(main category)`main where sub.product_id=main.product_id ; select sub.sub_product_image_path, sub.su

如果我把你的要求弄对了,那就行了

select sub.sub_product_image_path, sub.sub_product_id 
    from `portal_products(sub category)` sub , 
         `portal_products(main category)`main 
  where sub.product_id=main.product_id ;

select sub.sub_product_image_path, sub.sub_product_id 
    from `portal_products(sub category)` sub  
  where sub.product_id=35;


使用Union或Union ALL将“门户_产品(子类别)”描述为表名的错误选择将是轻描淡写的
select sub.sub_product_image_path,sub.sub_product_id 
 from `portal_products(sub category)` sub 
 inner join  `portal_products(main category)`main  on
 sub.product_id=main.product_id 
 where sub.product_id=35;
select sub.sub_product_image_path, sub.sub_product_id 
from `portal_products(sub category)` sub , 
inner join `portal_products(main category)`main  on sub.product_id=main.product_id ;

union  all

select sub.sub_product_image_path, sub.sub_product_id 
from `portal_products(sub category)` sub  
where sub.product_id=35