Left Join not returning all rows
Posted
by DisgruntledGoat
on Stack Overflow
See other posts from Stack Overflow
or by DisgruntledGoat
Published on 2010-04-23T16:45:14Z
Indexed on
2010/04/23
16:53 UTC
Read the original article
Hit count: 264
I have this query in MySQL:
SELECT pr.*, pr7.value AS `room_price_high`
FROM `jos_hp_properties` pr
LEFT OUTER JOIN `jos_hp_properties2` pr7 ON pr7.property=pr.id
WHERE pr7.field=23
The jos_hp_properties
table has 27 rows but the query only returns one. Based on this question I think it may be because of the WHERE clause. The jos_hp_properties2
table has fields id, property, field, value, where field
is a foreign key to a third table (which I don't need to get data from).
Is there a way to select all the rows from the first table, including the value from table #2 where the field is 23 (or NULL if there is no field 23)?
© Stack Overflow or respective owner