英文:
How can I create view with multiple name of columns?
问题
我在SQL问题上遇到了一些困难,我需要连接数据库中的所有表,但当我编写这个问题时,我只从“klienci”表中获取值,并按其余表的顺序排列。我还需要使用别名,因为接下来我需要用这个问题创建视图:
SELECT idk, klienci.nazwa AS nazwa_klienta, miasto, adres, telefon
FROM klienci
LEFT JOIN zamow ON idk=k_id
LEFT JOIN detal_zamow ON idz=z_id
LEFT JOIN produkty ON idp=p_id;
英文:
I have problem with question in SQL, I need to join all tables from base but when I write this question I get only values from table "klienci" in order of rest tables. I need to use alias also, because next I need to create view with this question:
SELECT idk, klienci.nazwa AS nazwa_klienta, miasto, adres, telefon
FROM klienci
LEFT JOIN zamow ON idk=k_id
LEFT JOIN detal_zamow ON idz=z_id
LEFT JOIN produkty ON idp=p_id;
答案1
得分: 1
SELECT k.idk, k.nazwa AS nazwa_klienta, k.miasto, k.adres, k.telefon,
z.,det_zam.,prod.*
FROM klienci AS k
LEFT JOIN zamow AS z ON k.idk=z.k_id
LEFT JOIN detal_zamow AS det_zam ON k.idz=det_zam.z_id --????
LEFT JOIN produkty AS prod ON k.idp=prod.p_id; --???
英文:
SELECT k.idk, k.nazwa AS nazwa_klienta, k.miasto, k.adres, k.telefon,
z.*,det_zam.*,prod.*
FROM klienci as k
LEFT JOIN zamow as z ON k.idk=z.k_id
LEFT JOIN detal_zamow as det_zam ON k.idz=det_zam.z_id --????
LEFT JOIN produkty as prod ON k.idp=prod.p_id; --???
Not sure, but may be something like this. Without tables structure not sure about the two last JOINs
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论