Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Graeme Porter
3,341 PointsError in Treehouse page?
Hi - I'm completing the SQL / PHP course and I'm stuck on the SELECT statement... or rather it's stuck?
I enter "SELECT 'price', 'name' FROM products" and the result says I've failed and shows this error...
f1705544-0c3f-4631-a4c4-d5185a161a1f.rb:37:in eval': undefined method
to_a' for # (NoMethodError) from f1705544-0c3f-4631-a4c4-d5185a161a1f.rb:37:in eval' from f1705544-0c3f-4631-a4c4-d5185a161a1f.rb:37:in
'
SO... how do I complete the module?
2 Answers

Alex Hedley
16,378 PointsTry removing the single quotes from the field names:
"SELECT price, name FROM products"

Graeme Porter
3,341 PointsOK, that got it. Odd thing to have to do though, no?
Anyhoo - all is well, cheers Alex.

Alex Hedley
16,378 PointsBecause you wrapped the field names in quotes it is then treating the value as a string literal instead of an actual fields.
Say you had a WHERE clause and you wanted it to be equal to some value you would wrap it there:
"SELECT price, name FROM products WHERE name='apple' "

Graeme Porter
3,341 PointsWhat a douche... work THEN beer next time. Cheers Alex!