Zdravim,
mam nasledujuci dotaz:
SELECT typ_tovaru.nazov AS "nazov",
SUM(IF(tovar.ID_typu = 1, faktura.mnozstvo * tovar.cena, 0)) AS "Slovinsko",
SUM(IF(tovar.ID_typu = 2, faktura.mnozstvo * tovar.cena, 0)) AS "UK",
SUM(IF(tovar.ID_typu = 3, faktura.mnozstvo * tovar.cena, 0)) AS "Ceska Republika",
SUM(IF(tovar.ID_typu = 4, faktura.mnozstvo * tovar.cena, 0)) AS "Ceska Republika",
SUM(IF(tovar.ID_typu = 5, faktura.mnozstvo * tovar.cena, 0)) AS "Ceska Republika",
SUM(IF(tovar.ID_typu = 6, faktura.mnozstvo * tovar.cena, 0)) AS "Holandsko",
SUM(IF(tovar.ID_typu = 7, faktura.mnozstvo * tovar.cena, 0)) AS "Ceska Republika",
SUM(IF(tovar.ID_typu = 8, faktura.mnozstvo * tovar.cena, 0)) AS "USA",
SUM(faktura.mnozstvo * tovar.cena) AS "celkove prijmy"
FROM faktura INNER JOIN tovar ON faktura.ID_tovaru = tovar.ID_tovaru INNER JOIN typ_tovaru ON typ_tovaru.ID_typu = tovar.ID_typu INNER JOIN vyrobcovia ON vyrobcovia.ID_vyrobcu = tovar.ID_vyrobcu
GROUP BY typ_tovaru.nazov;
Ked ho vlozim cez phpMyAdmin tak vsetko prebehne bez problemov. Ked ulozim SELECT do premennej $finalselect a spustim dotaz v PHP kode:
$result = @mysql_query($finalselect);
if (!$result) {
exit( mysql_error() . '</p>');
}
tak vyhodi chybu:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '
SUM(IF(tovar.ID_typu = 1, faktura.mnozstvo * tovar.cena, 0)) AS "Slovinsko' at line 1
vobec neviem co moze byt zle a uz som zufaly. Dakujem za pomoc smiling smiley
Příspěvky odeslané z IP adresy 82.119.233.–
kecinko