Temos pavadinimas: WordPress, Shopify ir PHPFusion programuotojų bendruomenė :: Nesigauna užkl su where

Parašė Narysx· 2009 Bal. 2 22:04:25
#1

$query = dbquery("SELECT games.te_id, AVG( score ) AS pts, te_name, te_city
         FROM (
           SELECT ga_home_id AS te_id, ga_home_score AS score FROM prefix_games
           UNION
           SELECT ga_away_id AS te_id, ga_away_score AS score FROM prefix_games) AS games,
           prefix_teams WHERE te_division='0' OR te_division='1' OR te_division='2'
           AND games.te_id = prefix_teams.te_id
           GROUP BY te_id
           ORDER BY pts DESC");




Kas blogai?

Redagavo Narysx· 2009 Bal. 2 22:04:28

Parašė bruzgis· 2009 Bal. 2 23:04:24
#2

tu geriau pasakyk ka ir iskeliu duombaziu nori istraukt nes cia tavo tos uzklauso tai dieve apsaugok :)
ir siaip bandyk uzmest dar () apskliaudziant visus OR

$query = dbquery("SELECT games.te_id, AVG( score ) AS pts, te_name, te_city
FROM (
SELECT ga_home_id AS te_id, ga_home_score AS score FROM prefix_games
UNION
SELECT ga_away_id AS te_id, ga_away_score AS score FROM prefix_games) AS games,
prefix_teams WHERE (te_division='0' OR te_division='1' OR te_division='2')
AND (games.te_id = prefix_teams.te_id)
GROUP BY te_id
ORDER BY pts DESC");
:s

Redagavo bruzgis· 2009 Bal. 2 23:04:36

Parašė Narysx· 2009 Bal. 2 23:04:53
#3

;D Iš vienos duom. bazės, bet iš dviejų lentelių. Šiaip tai ne mano rašyta šita užkl. aš ją tik paredagavau. Va kokia ji buvo prieš redaguojat:


$query = dbquery("SELECT games.te_id, AVG( score ) AS pts, te_name, te_city
         FROM (
           SELECT ga_home_id AS te_id, ga_home_score AS score FROM prefix_games
           UNION
           SELECT ga_away_id AS te_id, ga_away_score AS score FROM prefix_games) AS games,
           prefix_teams WHERE games.te_id = prefix_teams.te_id
           GROUP BY te_id
           ORDER BY pts DESC");




Čia ima info iš prefix_games ir prefix_teams lentelių, o aš noriu dar dadėt, kad imtų tik ten, kur prefix_teams lentelėje te_division='0' OR te_division='1' OR te_division='2' :)

Redagavo Narysx· 2009 Bal. 2 23:04:04

Parašė bruzgis· 2009 Bal. 2 23:04:30
#4

naudok inner join tada...

http://www.w3schools.com/Sql/sql..._inner.asp

Parašė ramon· 2009 Bal. 2 23:04:01
#5

Jei nesigauna su join td darik 2 uzklausas :)

Parašė Narysx· 2009 Bal. 3 16:04:20
#6

chipass parašė:
tu geriau pasakyk ka ir iskeliu duombaziu nori istraukt nes cia tavo tos uzklauso tai dieve apsaugok :)
ir siaip bandyk uzmest dar () apskliaudziant visus OR

$query = dbquery("SELECT games.te_id, AVG( score ) AS pts, te_name, te_city
FROM (
SELECT ga_home_id AS te_id, ga_home_score AS score FROM prefix_games
UNION
SELECT ga_away_id AS te_id, ga_away_score AS score FROM prefix_games) AS games,
prefix_teams WHERE (te_division='0' OR te_division='1' OR te_division='2')
AND (games.te_id = prefix_teams.te_id)
GROUP BY te_id
ORDER BY pts DESC");
:s


Suveikė. :) Ačiū.