Ceriwis  

Go Back   Ceriwis > HOBI > Komputer & Teknologi > Programming

Programming Share, tanya jawab, saling bantu antar programmer dengan berbagai macam bahasa pemrograman.

Reply
 
Thread Tools
  #1  
Old 20th November 2011
Guesuper Guesuper is offline
Ceriwiser
 
Join Date: Nov 2011
Posts: 408
Rep Power: 14
Guesuper mempunyai hidup yang Normal
Default [ASK SQL] Join 1 ID 2 FK dalam 1 Table

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



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..



Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


 


All times are GMT +7. The time now is 05:22 AM.


no new posts