mysql - How to join tables together - SQL -
this sql question
i have 2 tables need join together, using inner join syntax. 1 named entry, , other named prize. need list event_id, horse_id, place, money
.
entry (table name) columns in table entry: event_id, horse_id place prize (table name) columns in table prize: event_id, place, money
this far have got, can't head around it.
select event_id, horse_id, place entry inner join prize on entry.money = prize.money
thanks
select e.event_id, e.horse_id, e.place, p.money entry e join prize p on e.event_id = p.event_id e.place = p.place;
the e , p used aliases tables avoid unreadable sql because of long table names.
using e. or p. select field table because possible both tables have field same name there issues when executing statement
i added e.place = p.place because if don't getting results every place each event matched every prize
for example event 1 horse 1 place 1 prize 1 event 1 horse 1 place 1 prize 2 event 1 horse 1 place 1 prize 3 event 1 horse 1 place 1 prize 4 etc... until every prize , same every entry, assuming event prize equals event entry
Comments
Post a Comment