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?
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
Projection, according to this Article 'is selecting the name of the columns of table(s) which one wishes to see appearing in the answer'.
Example (removed a previous example that may have been confusing)
SELECT Col1, Col2 FROM [Table1]
Selection, uses WHERE Clauses to reduce the resultset and doesnt say anything about filtering columns.
SELECT * FROM [Table1] WHERE [Col1] = 'Result'
In SQL,these can be used in combination, ie. WHERE Clause and with filtering Columns;
SELECT Col1, Col2 FROM [Table1] WHERE [Col1] = 'Result'
Regards,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With