Difference between * and c.*

Screen Link:

https://app.dataquest.io/m/190/building-and-organizing-complex-queries/4/creating-views

<!--Enter other details below: -->

please can someone explain the difference between * and c.* and when to use either? the course says the wildcard returns all columns in the table. but isnt that what * does too? interchanging them in this mission returns very different results.
1 Like
  1. * - select all column in a table
  2. c.* - select all columns from table c.

The best method is 2. Always specify the table name.

3 Likes

Hi @rayolufadeju:

As @info.victoromondi has said, for c.*, it is used to select columns from a table. Usually this is done when you INNER JOIN 2 or more tables together and use c as an alias for the table name. For example the table name maybe Chinook. Note that I come from a Microsoft SQL Server background so do feel free to correct me.

Hope this helps!
R

1 Like

Hi @rayolufadeju, the asterisk or star symbol ( * ) used in a SELECT clause means select all columns from the table or tables specified in the FROM clause of a SQL query. As @masterryan.prof and @info.victoromondi have pointed out when you want to select all the columns in one table usually in cases where multiples tables are specified in the FROM clause, then you use the tablename.* or table alias.* notation. So c.* means select all columns from table c or table with an alias c.

4 Likes