I was given this question about an interview with MySQL that made me disqualified for work.
I went for an interview and asked a question that I could not answer, and I lost my job.
They asked.
We have two tables, the first table (main table) CANDIDATESwith fields:
candidate_id (primary_key)candidate_name
The second table (child table) CANDIDATE_VOTESwith the fields:
v_id (primary key)candidate_id (external key)
Each time a vote is given, the candidate candidate_key is placed in the child.
CANDIDATE:
=================================
|candidate_id | candidate_Name |
|-------------------------------|
| 1 | abc |
|-------------------------------|
| 2 | xyz |
|-------------------------------|
| 3 | etc |
|-------------------------------|
CANDIDATE VOTES
==========================
| votes_id | candidate_id |
|-------------------------|
| 1 | 1 |
|-------------------------|
| 2 | 1 |
|-------------------------|
| 3 | 2 |
|-------------------------|
Question: How will you announce the winner?
Please help me how to do this.
I tried a lot, but could not find the logic.
source
share