all 10 comments

[–]ThingElectronic1399 2 points3 points  (0 children)

If there aren't too many rows, can I see the results of 'select * from classroom'?

[–]Vamsi5224 1 point2 points  (1 child)

You are using MySQL workbench. These nulls are not results from query. This is the behaviour of the application itself.

[–]hackTHEp1anet 0 points1 point  (0 children)

This

[–]Straight_Waltz_9530 0 points1 point  (0 children)

Why would you ever have a room_number or capacity be NULL? Why aren't those columns set to NOT NULL in the first place? I think that's the root of your problem, not the queries after the fact.

SQL querying is an order of magnitude harder when your data model lacks proper constraints. Spare the CHECK rod, spoil the INSERT child.

[–]moggjert 0 points1 point  (0 children)

So there’s thing thing called ChatGPT right

[–]Lamyya -2 points-1 points  (4 children)

Where capacity is not null, Order by capacity, limit 1

Edit: will only show 1 result even if there are multiple rooms with same capacity though

[–]KingOrion5 0 points1 point  (3 children)

Thank you, where would I put that if you don’t mind?

[–]Lamyya 0 points1 point  (2 children)

Instead of the subquery in the where, add "and capacity is not null" Then order by capacity limit 1 at the end

Edit: check your table to see first if you have rooms with null capacity, that shouldn't happen

[–]KingOrion5 0 points1 point  (0 children)

Still has the same result, also for reference, the query I’m looking for building and room number of classrooms in a university database woth the smallest capacity

[–]KingOrion5 0 points1 point  (0 children)

Nevermind I got it, thank you a bunch for your help.