Fields from table TICKETS:
ID TICKETID CUSTOMER
234 29 9798797
235 76 7887878
Fields from table RECEPTS:
ID DATENEW TOTAL
234 2012-12-03 22.57
235 2012-12-03 33.98
Fields from table PAYMENTS:
RECEIPT PAYMENT
234 cash
235 debt
Fields from table CUSTOMERS:
ID NAME
9798797 John
7887878 Helen
The relation between tables is very easy to understand: TICKETS.CUSTOMER=CUSTOMERS.ID; PAYMENTS.RECEIPT=RECEIPTS.ID=TICKETS.ID
The Final Result I would like to achive to have:
TICKETID DATENEW NAME PAYMENT TOTAL
29 2012-12-03 John cash 22.57
76 2012-12-03 Helen debt 33.98
I tried to do something like this but it wrong somewhere:
Select TICKETS.TICKETID, RECEIPTS.DATENEW, PAYMENTS.TOTAL, CUSTOMERS.NAME, PAYMENTS.PAYMENT FROM PEOPLE, RECEIPTS
INNER JOIN TICKETS ON RECEIPTS.ID = TICKETS.ID
INNER JOIN CUSTOMERS ON TICKETS.CUSTOMER = CUSTOMERS.ID
ORDER BY RECEIPTS.DATENEW
Peoplein the from clause where you are not selecting anything from it, nor you sepecified the join condition of it with the other tables?