Mailinglisten-Archive |
News schrieb:
> Hallo,
>
> ich habe 3 tabellen
>
> 1. Einer Haupttabelle mit Hotels
> 2. Eine tabelle mit Bildern
> 3. Eine Quertabelle di enur dazu da ist id des Hotels mit einer ID eines
> Images zu verbinden.
>
>
> Jetzt versuche ich alle Hotels auszulesen und wnen vorhanden dazu
> passend die Bidler und zwar mit:
>
>
> SELECT t1.*, t2.image
> FROM gs_hotel as t1
> LEFT JOIN gs_image as t2, gs_image_to_hotel as t3
> ON (t2.id = t3.imageid AND t2.foto=1 AND t3.hotelid=t1.id)
> WHERE 1=1 AND t1.country=1
>
> Klappt aber nicht. Es wird ein SQl Fehler ausgegeben
>
> Was mache ich falsch ?
du verwendest das JOIN falsch
SELECT t1.*,
t2.image
FROM gs_hotel AS t1
LEFT JOIN gs_image_to_hotel AS t3
ON t3.hotelid = t1.id
LEFT JOIN gs_image AS t2
ON t2.id = t3.imageid
AND t2.foto = 1
WHERE t1.country = 1
p.s. es ist ein kleiner aber feiner unterschied ob das "t2.foto = 1"
beim JOIN oder beim WHERE steht, weiß allerdings nicht was du genau
brauchst ...
--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetime www.sf.net/projects/phptimesheet
php::bar PHP Wiki - Listenarchive