Union standart so‘zidan foydalanish
Download 25.83 Kb.
|
11 Union standart so‘zidan foydalanish
Union standart so‘zidan foydalanish. MySQL UNION operatori ikki yoki undan ortiq natijalar to'plamini bitta natijalar to'plamiga birlashtirishga imkon beradi. UNION operatorining sintaksisini quyidagilar aks ettiradi: SELECT column_list UNION [DISTINCT | ALL] SELECT column_list UNION [DISTINCT | ALL] SELECT column_list ... UNION operatorini qo’llash uchun quyidagi qoidalar mavjud: Birinchidan, barcha SELECT operatorlarida paydo bo'ladigan ustunlar soni va tartiblari bir xil bo'lishi kerak. Ikkinchidan, ustunlarning ma'lumotlar turlari bir xil yoki mos bo'lishi kerak. Odatda UNION operatori takrorlanuvchi satrlarni o’chiradi. UNION operatorining Venn diagrammasi orqali ko’rinishi: SELECT firstName, lastName FROM employees UNION SELECT contactFirstName, contactLastName FROM customers; SELECT
FROM employees UNION SELECT CONCAT(contactFirstName,' ',contactLastName) FROM customers; SELECT
'Employee' as contactType FROM employees UNION SELECT CONCAT(contactFirstName, ' ', contactLastName), 'Customer' as contactType FROM customers ORDER BY fullname Download 25.83 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling