Jump to content
php.lv forumi

2 tabulu linkošana


aika

Recommended Posts

Neesmu īsti pārliecināts vai tas vispār ir iespējams:

atlasīt datus no 1 tabulas pievienojot datus no 2trās (pat ja attiecīga rinda tajā neksistē)

respektīvi:

Tabula 1: keys; vērtība

a 1

b 2

c 3

Tabula 2: keys; vērtība

a 4

c 5

Atgriezt:

a 1 4

b 2

c 3 5

Link to comment
Share on other sites

Ir iespējams:

SELECT t1.keys, t1.vertiba, t2.vertiba FROM tabula1 AS t1 LEFT JOIN tabula2 AS t2 ON t1.keys = t2.keys

 

Tajā gadījumā, kad tabulā2 nebūs šāda keya, trešā kolonnaa saturēs NULL

 

NU jā, tā strādā! Es jau nebūtu prasījis, ja nebūtu pirms tam pats mēģinājis. Vnk sintakse nebija pareiza. Paldies!

Link to comment
Share on other sites

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