Today's writing is really short and is a poll. So please use the comment feature to answer it. Let consider the tables below for a relational schema about people owning pictures (I suppose that a BLOB column could hold the picture, but this is not important here):
Now, consider the following SQL query that returns the whole people
info as well as the number of pictures
each of them has in the database:
SELECT id,
email,
name,
(SELECT count(*)
FROM pictures
WHERE pictures.owner = people.id) as nb_picts
FROM people
Here is the poll. How do you feel?
- Exactly what you'd have written
- You prefer to use a GROUP BY
- It's probably correct, but you're not sure
- You would never write such a query, it's certainly inefficient
- The query is incorrect, not allowed in SQL
- Other (please explain)
Post your response as a 1-6 number using the comment feature below (there is no particular trap).
Thanks!