Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

SELECT * FROM movies WHERE actors LIKE '%Tom'; //Not sure where the error is

The question is asking me to query and select a column named actors and then to find the row with the name 'Tom'.

Here is my code.

SELECT * FROM movies WHERE actors LIKE '%Tom';

please help!

Try:

SELECT * FROM movies WHERE actors LIKE '%Tom%';

The error that I'm getting is that it says SQL ERROR; no such column: actors

But the issue is that this is what the question is asking me. Copy and pasted below.

Challenge Task 4 of 4 Select all actors whose name starts with "Tom".

maybe it's "actor" not "actors", which would honestly make more sense.

Also, if the name starts with "Tom" it should be

SELECT * FROM movies WHERE actor LIKE 'Tom%';

Thanks for the suggestion Jacques Vincilione , but it says no column named 'actor' as well.

Can you post the link to the exact question? Just copy/paste the url.

http://teamtreehouse.com/library/database-foundations/reading-data-from-databases-with-sql/ordering-the-result-set

It's challenge 4 of 4. I'm sure I'm making a simple mistake but I can't see where. Thanks for being so helpful!

No problem. The issue is that you are querying the wrong table.

SELECT * FROM actors WHERE name LIKE 'Tom%'

Yes!! Thank you! It was killing me!

I added it as an answer if you don't mind marking it correct.

Yea I was actually just looking to do that. LOL!

4 Answers

The issue is that you are querying the wrong table.

SELECT * FROM actors WHERE name LIKE 'Tom%'

If i recall correctly you are querying the incorrect table

SELECT * FROM actors WHERE name LIKE "%TOM%";

or first_name... I can't recall so far as to remember the exact column names. But I do remember that that tutorial involves a table named 'actors'

Not familiar with your project, but .... Your query would match "xTom" but not "Tomx" or "Tom x" The percent sign (%) is a wild card. Assuming the actors column contains first and last names concatenated into a single field, you just need to change the position of your wild card, like so ...

SELECT * FROM movies WHERE actors LIKE 'Tom%';

The error that I'm getting is that it says SQL ERROR; no such column: actors

But the issue is that this is what the question is asking me. Copy and pasted below.

Challenge Task 4 of 4 Select all actors whose name starts with "Tom".

This worked for me:

SELECT * FROM actors WHERE name LIKE "%Cruise";