Jump to content

Selection problem, all data is corect


ebchost

Recommended Posts

$utakmice = mysql_query("
SELECT 
`man_timovi`.`id`, 
`man_timovi`.`naizv`, 
`man_timovi`.`user_id`, 
`man_utakmice`.`id`,
`man_utakmice`.`liga_id`, 
`man_utakmice`.`sezona_id`, 
`man_utakmice`.`kolo`, 
`man_utakmice`.`datum,
`man_utakmice`.`domacin`, 
`man_utakmice`.`brojd`, 
`man_utakmice`.`gold`, 
`man_utakmice`.`golg`, 
`man_utakmice`.`brojg`, 
`man_utakmice`.`gost`, 
SUM(`man_utakmice`.`bodd` + `man_utakmice`.`bodg`)

FROM `man_timovi`,`man_utakmice` 

WHERE `man_utakmice`.`liga_id`= '1' AND `man_timovi`.`id` = `man_utakmice`.`domacin` OR `man_timovi`.`id`=`man_utakmice`.`gost`

GROUP BY `man_timovi`.`id`

ORDER BY SUM(`man_utakmice`.`bodd`+`man_utakmice`.`bodg`) DESC") or die(mysql_error());

while($row = mysql_fetch_array($utakmice))
{
..
}

 

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 '`.`domacin`, `man_utakmice`.`brojd`, `man_utakmice`.`gold`, `man_utakmice`.`g' at line 9

 

man_timovi:

id, liga_id, naziv, user_id berger, sifra

 

man_utakmice:

id, liga_id, sezona_id, kolo, datum, domacin, brojd, gold , golg, brojg, gost, bodd, bodg

 

 

Link to comment
https://forums.phpfreaks.com/topic/253771-selection-problem-all-data-is-corect/
Share on other sites

Your kidding aren't you?

 

i mast write SQL with out ``

 

thanks

 

Pardon?

 

SELECT 
man_timovi.id, 
man_timovi.naziv, 
man_timovi.liga_id,  
SUM( gold ) , SUM( golg ) , SUM( bodd ) , SUM( bodg ) 
FROM man_timovi, man_utakmice
WHERE man_timovi.liga_id = '1'
AND man_timovi.id = man_utakmice.domacin
OR man_timovi.id = man_utakmice.gost
GROUP BY  man_timovi.id 
ORDER BY SUM(  `man_utakmice`.`bodd` +  `man_utakmice`.`bodg` ) DESC 

 

the only thing bothering me now is, which is still showing data for the league labeled liga=2, liga=3 .. I want only league 1 (liga_id = 1)

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.