Database question!

Asked 2 years ago, Updated 2 years ago, 48 views

Hello, I am a student who is studying at the academy.
I'm working on a project, but I'm in trouble because the database connection is slow. I'm asking because I'm curious if it's because the grammar is too complicated!!

The database is located in the room_log

Column 1 room_number
Column 2 guest_id
Column 3 message
Column 4 time
select room_number from (
    select room_number from room_log where guest_id='Hakwon Girl'
    intersect
    select room_number from room_log where guest_id='Academic Man'
);

What I am currently making is a messenger program The conditions I'm looking for are guest_id="Hakwonman" and guest_id="Hakwongirl" It's a conversation we had in the same room.

I would appreciate it if you could let me know if there is anything to improve!

oracle java sql

2022-09-20 22:23

1 Answers

I haven't tested it, but maybe you can do it this way.

SELECT *
FROM room_log logGIRL
JOIN room_log  logMAN ON logMAN.room_number = logGIRL.room_number
WHERE logGIRL.guest_id = "Gakuen Girl"
  AND logMAN.guest_id = 'Academic Man'
ORDER BY time DESC;


2022-09-20 22:23

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.