-1

I have two tables 'projects' and 'overground' - when I run this query I get the ID from the overground value (40), not the value it holds which should be 'Forest Hill'.

SELECT * 
FROM projects 
JOIN overground ON projects.overground_id=overground.overground_id 
WHERE name = 'The Horniman Museum & Gardens '

I'm confused about my query, I need all rows from 'projects' (in this case from the "The Horniman Museum & Gardens") and the value from 'overground_id' (='forest hill).

I think it's something to do with the WHERE clause, but not sure.

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • 1
    If you run the query straight on the MySQL database from something like a GUI rather than in PHP does it still return incorrectly? – owenmelbz Jun 17 '15 at 07:05

1 Answers1

0

Why not try something like this instead:

SELECT * 
FROM projects, overground
WHERE projects.overground_id=overground.overground_id AND projects.name='The Horniman Museum & Gardens'

Personally, I just prefer avoiding explicit joins when possible just for simplicity but to each their own.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Grant P
  • 85
  • 7
  • Thanks for your reply, unfortunately, I'm still getting the same result. "40" is echo'd, and not the value 'Forest Hill'. Baffled. Thanks for your help. – CallMePhilip Jun 16 '15 at 21:57
  • my overground table looks like... [ overground_id | overground_name ] - have I missed something out? – CallMePhilip Jun 16 '15 at 21:59