Ceriwis

Ceriwis (https://forum.ceriwis.com/forum.php)
-   Programming (https://forum.ceriwis.com/forumdisplay.php?f=63)
-   -   [ASK SQL] Join 1 ID 2 FK dalam 1 Table (https://forum.ceriwis.com/showthread.php?t=575093)

Guesuper 20th November 2011 10:51 AM

[ASK SQL] Join 1 ID 2 FK dalam 1 Table
 

misi mastah, maap kalo judulnya agak membingungkan :D abis ane juga lagi bingung nih :D



untuk lebih jelasnya gini :

ada 2 table

1. Table Owner

2. Table Receipt



Di table receipt ada 3 column

1. receipt_id INT PRIMARY KEY

2. owner_id INT FK

3. slot_owner INT



isi dari column slot_owner itu bisa aja sama kayak owner_id tapi bisa juga beda, owner_id ini diambilnya dari table Owner



ane bingung kalo selectnya jika yang mau ditampilin sebagai berikut :

Receipt ID | Owner Code | Slot Owner



ane udah pake cara gini :


Code:

SELECT receipt.*,
owner.*
FROM receipt
JOIN owner ON owner.owner_id=receipt.owner_id
JOIN owner ON owner.owner_id=receipt.slot_owner

pake code di atas kaga bisa gan..



gimana ya caranya tanpa nambah table lagi ??

mohon analisanya gan.. :ceriwislove:

</div>


All times are GMT +7. The time now is 10:39 PM.