17 Şubat 2009 Salı

ileri sql

SELECT 
siparis_id,
siparis_tutari,
siparis_tarihi,
uye_id,
(select ad+' '+soyad from uyeler where uye_id=siparisler.uye_id) as uye,
(select adres+' '+semt+'/'+ (select sehir_adi from sehirler where sehir_kodu=sehir) from adresler where adres_id=siparisler.adres_id) as adres,
(select kargo_adi from kargolar where kargo_id = siparisler.kargo_id) as kargo
FROM
siparisler

SELECT siparis_id, siparis_tutari, siparis_tarihi, uye_id,
(SELECT ad + ' ' + soyad AS Expr1
FROM uyeler
WHERE (uye_id = siparisler.uye_id)) AS uye,
(SELECT adres + ' ' + semt + '/' +
(SELECT sehir_adi
FROM sehirler
WHERE (sehir_kodu = adresler.sehir)) AS Expr1
FROM adresler
WHERE (adres_id = siparisler.adres_id)) AS adres,
(SELECT kargo_adi
FROM kargolar
WHERE (kargo_id = siparisler.kargo_id)) AS kargo, onay
FROM siparisler

Hiç yorum yok: