I have two tables:
ReservationName
+-------+-------+-------+-------+ | Name | +-------+-------+-------+-------+ | Brad Pitt | | Morgan Freeman | | Bobby deniro | +-------+-------+-------+-------+ BookingDetails
+-------+-------+-------+-------+ | Name | ID | Eid | +-------+-------+-------+-------+ | Brad Pitt | 1 | ab123 | | Morgan Freeman | 2 | pq123 | | Bobby deniro | 3 | rs123 | +-------+-------+-------+-------+ I have to match the names in ReservationName with BookingDetails .
If they are same (count and value) .
Above example of mine should return true as names are identical and count is 3. The aforementioned condition is part of If exists logic that I am using in a stored procedure.
SELECT *, count(*) nameCount FROM ReservationName t1 JOIN BookingDetails t2 ON (t1.Name = t2.Name)will return all the matched rows. I don't understand the exact requirement but I think thats what you want.