开发者

get data form 'dictionary' table

开发者 https://www.devze.com 2023-01-19 02:06 出处:网络
I have two tables in database: A: [ ID, name, SECRET_KEY] examplary rows: ID1, John, X ID2, Jane, Y and second ( \'dictionary\')

I have two tables in database:

A: [ ID, name, SECRET_KEY]

examplary rows:

ID1, John, X
ID2, Jane, Y

and second ( 'dictionary')

B: [SECRET_KEY, explanation]

like:

X, Driver
Y, Doctor

i want to list all records from table A but with secret_key开发者_开发知识库 translated to it's explanation ( based on relation from table B).

expected result:

ID1, John, Driver
ID2, Jane, Doctor

I suppose it is very easy but i cannot figue how to do it based on wc3 tutorials :-|. I would be glad if u share with me link to good sql tutorial too.

thanks.


select A.ID, A.name, B.Explaination 
from A inner Join B On A.Secret_Key = B.Secret_Key


SELECT a.ID, a.name, b.explanation
  FROM a LEFT JOIN b USING(secret_key)
0

精彩评论

暂无评论...
验证码 换一张
取 消