Jump to content
php.lv forumi

Recommended Posts

Posted (edited)

Palīdziet iesācējam ;)

man ir Mysql tabula "kom" kurā ir ID un NAME

un tabula "rez" kurā ir KOM_ID1, KOM_ID2, REZ1, REZ2

kā lai es izvadu visus "rez", bet "kom_id1", "kom_id2" ieliekot NAME no tabulas "kom"

pašlaik rādās
team1|team2|rez1|rez2
1|2|8|7
2|4|7|9

kā vajadzētu:
team1|team2|rez1|rez2
Name1|Name2|8|7
Name2|Name4|7|9

SELECT * FROM rez WHERE someid=$id JOIN ?

Edited by Kaspars Ozols
Posted
SELECT
    k1.NAME,
    k2.NAME,
    rez.REZ1,
    rez.REZ2
FROM rez
INNER JOIN kom k1 ON k1.ID=rez.KOM_ID1
INNER JOIN kom k2 ON k2.ID=rez.KOM_ID2

Linku uz mysql manuāli jau atradi?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...