I have a mess of queries and i want to see if I can get most of them combined into one query to then echo out elements on a page with php.
But that's a level of query-building a bit beyond my level...
Everything depends on the numeric id variable ($id) Limited to just one result.
I tried just a simple union between each, but got a warning of different number of columns.
Here are the pieces I have. Maybe somebody can make simpler sense of this soup:
SELECT descriptors.*, plantae.*, relationships.*, plant_pics.*
JOIN plantae ON descriptors.plant_id = plantae.plant_name
JOIN relationships ON relationships.plant_id = plantae.plant_name
LEFT JOIN plant_pics ON plant_pics.plant_id = plantae.plant_name AND plant_pics.part_id = 1
WHERE descriptors.plant_id = $id
SELECT DISTINCT continents.Name AS continent1,continent_regions.Name,country.Name AS country1, GROUP_CONCAT( states.Name SEPARATOR ', ') AS state1, plant_locations_link.plant_id
JOIN continents ON plant_locations_link.continents = continents.ID
JOIN continent_regions ON plant_locations_link.continent_regions = continent_regions.ID
JOIN country ON plant_locations_link.country = country.ID
JOIN states ON plant_locations_link.state = states.ID
WHERE plant_locations_link.plant_id = $id
SELECT plant_term_id, plant_id, low_id, high_id, measurements1.*
AS lowest, measurements2.* AS highest,
measurement_terms.plant_term AS tpart, plant_parts.part AS ppart
JOIN measurement_terms ON plant_measures.plant_term_id =
JOIN plant_parts ON measurement_terms.id = plant_parts.id
LEFT JOIN measurements AS measurements1 ON plant_measures.low_id =
LEFT JOIN measurements AS measurements2 ON plant_measures.high_id =
WHERE plant_id = $id