Databases SQL Reporting by Example Orientation: Selecting Data Finding the ID

Teacher Russell
Teacher Russell
16,868 Points

Finding the ID

Any reason not to use SELECT ID FROM students ...... rather than SELECT * FROM students WHERE FIRST_NAME = "Yvette" AND LAST_NAME = "Levy"; ?

2 Answers

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 51,734 Points

In a program SELECT ID may be used so that you are not selecting more data than you need. But for purposes of an instruction video including the name (and other fields) may help confirm the selection was correct.

Since you are returning exactly one row of data then select all is preferred in order to have all column information present just in case you didn't know the table at all.