我有以下两个表:
USER
FID UID VALUE
4 3 John
3 3 Doe
4 4 Jack
3 4 Russel
应该很清楚 FID 3 = 姓氏,FID 4 = 名字。
DATEDATA
UID DATE
3 1234
4 4321
我想加入这两个表,所以我最终会得到这样的结果:
UID DATE NAME SURNAME
3 1234 John Doe
4 4321 Jack Russel
或者……或者……
UID DATE FULLNAME
3 1234 John Doe
4 4321 Jack Russel
那里有任何 SQL 大师吗?
这是我到目前为止所拥有的:
SELECT UID, DATE, VALUE
from DATEDATA as D
left join USER as U
on U.uid = D.uid where fid = 3 OR fid = 4
但这给了我这个:
UID DATE VALUE
3 1234 Doe
3 1234 John
4 4321 Russel
4 4321 Jack
任何人?