PHP Portal » PHP Forum » Entwicklung » MySQL, PostgreSQL und SQL-konforme Datenbanken » Datensatz komplett NULL statt kein Ergebnis » Antworten

Antwort erstellen

Titel
Formatierung
b i u
Beitrag  
Datei anhängen max: 2M
Optionen







Spamschutz Eingabeformat HH:MM

 

aber was ist hiermit

Code
1
INNER JOIN bundle_detail a0 ON ( a1.id = a0.bundle_id AND a1.from <= CURDATE( ) AND a1.to >= CURDATE( ) )

es gibt keinen Datensatz, welcher die Datumsbedingung erfüllt

 

Ich vermute den Fehler hier:

Code
1
IF( ISNULL( i.id ) , b.price, MIN( i.price ) ) AS `preis` ,


Wenn i.id NULL ist, soll b.price verwendet werden. Dieser ist aber u.U. auch NULL. Die WHERE bedingungen könnten aber dennoch passen. Was auch immer ... Ist nur ne Vermutung. ;-)

Datensatz komplett NULL statt kein Ergebnis 

Hallo,

ich starte eine SQL Anweisung an eine MySQL Datenbank, und erhalte einen Datensatz zurück,
welche komplett aus NULL-Werten besteht. Eigentlich sollte ich gar kein Ergebnis erhalten.
Auch EXPLAIN erklärt mir "Impossible WHERE noticed after reading const table...", also
hat er doch gar nichts zum selektieren.

Die Abfrage:

Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
SELECT `a`.`id` AS `id` , `a`.`store_id` AS `store` , `a1`.`name` AS `name` , `a1`.`id` AS `bundle` , `a`.`id` AS `product` , `i`.`id` AS `variation` , `b1`.`percent` AS `percent` , IF( ISNULL( i.id ) , b.price, MIN( i.price ) ) AS `preis` , `b`.`customer_group_id` AS `group` , `a1`.`smalltext` AS `kurztext` , `a1`.`text` AS `text` , `a1`.`image` AS `image` , `a1`.`alt` AS `alt` FROM bundle a1 INNER JOIN bundle_detail a0 ON ( a1.id = a0.bundle_id AND a1.from <= CURDATE( ) AND a1.to >= CURDATE( ) ) INNER JOIN product a ON ( a0.product_id = a.id ) INNER JOIN product_price b ON ( a.id = b.product_id ) INNER JOIN bundle_group b1 ON ( b.customer_group_id = b1.customer_group_id AND a1.id = b1.bundle_id ) LEFT JOIN product_variation_group i ON ( a0.product_variation_id = i.product_variation_id AND b.customer_group_id = i.customer_group_id ) WHERE a.store_id =1 AND b.customer_group_id =1 AND a1.id =1 ORDER BY name ASC

Kann mir das jemand erklären wo da mein Denkfehler ist?