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

Databases

SQL Query question i would not understand. Please help.

Here is the question: In the users table we have the columns id, username, password, first_name and last_name. Find all users with the first name starting with the letter "L".

I tried answering it this way but is not correct.

SELECT*FROM users WHERE first_name LIKE ("%L");

2 Answers

Laura Kyle
Laura Kyle
19,794 Points

You're so close! The % should go after the "L". Remember that the "%" is the wildcard, it goes where you're not sure what the content actually is. So if it starts with "L", then use "L%" as you're not sure what follows.

SELECT * FROM users WHERE first_name LIKE ("L%");

That answered and cleared confusion. Thank you so much for your help.

Amr Aly
Amr Aly
5,201 Points

("Here-Starts-with%") ("%Here-Ends-with")

I understand the difference now, thank you so much!