PHP / MYSQL - multiple tables in one query

I have 6 tables to display in a single query. At first I try to execute three tables, but there is an error, and I do not know why. I want to show all fields, but I tried using the first element code if you are going to work. Sorry, there is a mistake.

Error Warning: mysqli::query() [mysqli.query]: (21000/1242): Subquery returns more than 1 row in C:\wamp\www\DASMA\stockcard.php on line 541

I want to display all the data in my table if one of them has no data yet. Just without using an SQL join.

   |allinvty3|(masterfile)
      ----------------
      |in_code       |
      |ecr_desc      |
      |pric_cash  
      |qty           |
      |ite_desc      |
      ---------------


 |(barcode, soldout_dm , dm_stock_transfer, adjustment etc. 
    -all have same fieldname)|
              ----------------
              |itemcode      |
              |qty           |
              |date  
              |qty           |
              |status        |
              ---------------
<?php
$sql = "
    SELECT  (
    SELECT itemcode as bcode
    FROM   barcode 
    ) ,
    ( 
    SELECT itemcode as bsold
    FROM   soldout_dm 
    ) ,
    (
    SELECT itemcode as  bstock
    FROM   dm_stock_transfer
    ) 
    ";
$result = $conn->query($sql);
?>
+4
source share
2 answers

try it

<?php

$sql = 'select b.itemcode as bcode, s.itemcode as bsold, d.itemcode as bstock from barcode as b, soldout_dm as s, dm_stock_transfer as d';

$result = $con->query($sql);

?>
0
source
$sql="select t1.column, t2.column,t3.column,t4.column,t5.column,t6.column from t1,t2,t3,t4,t5,t6 ";

This type of query will help you retrieve data from all six tables.

0
source

Source: https://habr.com/ru/post/1657242/


All Articles