全局MySQL查询获取行

时间:2013-09-13 20:51:58

标签: php mysql

大家好我有这个全局的mysql查询

$table_res =  mysqli_query($GLOBALS["___mysqli_ston"], "SELECTtProduct.sProduct, tManufacturers.sManufacturer,
tSerie.sSerie, tApplication.sType, tApplication.sEngine, tApplication.sKiloWatt, tApplication.sHorsePower,
tApplication.sDate1, tApplication.sDate2 FROM tProduct INNER JOIN (tSerie INNER JOIN (tManufacturers INNER JOIN 
(tApplication INNER JOIN tApplicationProduct ON tApplication.nApplication = tApplicationProduct.nApplication) ON 
tManufacturers.nManufacturer = tApplication.nManufacturer) ON tSerie.nSerie = tApplication.nSerie) ON 
tProduct.nProduct = tApplicationProduct.nProduct WHERE sProduct = '$product'
ORDER BY tProduct.sProduct;");

如何通过记住查询错过Where参数来从此查询中获取行和字段。

1 个答案:

答案 0 :(得分:0)

也许你是在追求这样的事情,虽然坦率地说我发现这个命名政策已经贬低......

SELECT p.sProduct 
       , m.sManufacturer
       , s.sSerie
       , a.sType
       , a.sEngine
       , a.sKiloWatt
       , a.sHorsePower
       , a.sDate1
       , a.sDate2 
    FROM tProduct p
    JOIN tApplicationProduct ap
      ON ap.nProduct = p.nProduct 
    JOIN tApplication a
      ON a.nApplication = ap.nApplication
    JOIN tSerie s
      ON s.nSerie = a.nSerie
    JOIN tManufacturers m
      ON m.nManufacturer = a.nManufacturer
   WHERE p.sProduct = '$product' 
   ORDER 
      BY p.sProduct;