MySQL SELECT more than one

I have a table with column numbers number 1, 2, 3, etc. and room number 1000, 2000, 3000, etc. Room No. 2000 is used by sections 2 and 3.

I want the SQL code to select rooms that have been divided by several sections. Note that I have another column called days (Sat, Sun, Mon ..), and there are several rooms that are used by the same section more than once. For example, room 2000 is used by Mon, Tue. Therefore, using count () will not work.

I tried it

SELECT 
    roomNumber
FROM

    section
having
    count(section_number) > 1

but it didn’t work. Please, help

PS: I'm new to mySQL

+4
source share
2 answers

Try

Select roomNumber from section group by roomNumber having count(roomNumber) > 1
+2
source

. group by. .

select   roomNumber
from     section
group by roomNumber
having   count(section_number) > 1;

, .

+2

Source: https://habr.com/ru/post/1611359/


All Articles