Search code examples
sqlselectprojection

Syntax for projection in SQL


What is the difference, in terms of syntax, between selection (SELECT) and projection in SQL? I know that the first isolates rows and the second columns, but I don't know how to actually get a new table with the specified columns. What is the syntax for a projection?


Solution

  • The projection corresponds to the columns you select, the selection to the filter you define in your where clause:

    SELECT ID, NAME
    FROM PRODUCTS
    WHERE PRICE > 100;
    

    Here the projection corresponds to the ID and NAME columns whereas the selection corresponds to the price filter