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 CRUD Operations with PHP Reading and Writing Reports Totaling Time

Alex Bauer
Alex Bauer
9,426 Points

Can someone help me with AS keyword in SQL?

$sql = 'SELECT tasks.*, projects.title as project FROM tasks' . ' JOIN projects ON task.project_id = projects.project_id';

That's what Alena Holligan had in the project files for the query.

What I don't understand is everything in between the select and as keywords. I learned that what that is doing is aliasing the column name to become "project" in this case. I just don't understand the ".*, projects.title" part.

1 Answer

tasks.* selects all columns from table tasks which includes a column named title (tasks.title)

projects.title selects the 'title' column from the projects table

to differentiate between the two columns named title an alias of project for projects.title has been used.

Alex Bauer
Alex Bauer
9,426 Points

Now I understand, thank you. I really appreciate your help.