What I've got so far:
SELECT wall_paths.wall_id, wall_paths.wall_path,
dimensions.width, dimensions.height
FROM wall_paths
LEFT JOIN wall_dimensions
ON wall_paths.wall_id = wall_dimensions.wall_id
LEFT JOIN dimensions
ON wall_dimensions.dimension_id = dimensions.dimension_id
WHERE wall_paths.wall_id = 4;
The query is selecting redundant rows, I just would like to select the two paths along with the corresponding dimensions based on the wall_dimensions table. Something like below:
Expected result
Result with GROUP BY
in query
Please help on how to select something like the above.
Note: I've tried DISTINCT
as well on the query but returns an error.
The query results are as expected, actually. Makes sense when you see it, data-wise. The data model is setup incorrectly for this query.
Fiddle (original data model): http://sqlfiddle.com/#!2/8c1bf/1
Fiddle (modified data model): http://sqlfiddle.com/#!2/3d9b0/5
Not saying you should change your model, just pointing out the query runs as expected with the current schema.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.