I have a guest table and a booking table and I am attempting to query how to find guests who share the same last names with the same booking date.
The result should output their last_name and first_names without any duplicate results.
SELECT g1.first_name, g2.first_name, g1.last_name, b.booking_date FROM guest g1, guest g2 JOIN booking b ON id=booking_id WHERE g1.last_name = g2.last_name AND g1.id<>g2.id AND b.booking_date=b.booking_date;
When I run this, I get back the empty set.
Where am I going wrong?