bubu Posted September 19, 2005 Report Share Posted September 19, 2005 Nekas nebūs. Tas having netraucēs. Link to comment Share on other sites More sharing options...
Analgiins Posted September 19, 2005 Report Share Posted September 19, 2005 tieshaam: SELECT COUNT(*) FROM `user` WHERE username = 'admin' SELECT COUNT(*) FROM `user` HAVING username = 'admin' manupraat otrais vaicaajusm ar HAVING izdos kljuudu Unknown column 'username' in 'having clause' Link to comment Share on other sites More sharing options...
Lynx Posted September 19, 2005 Report Share Posted September 19, 2005 Njā tā ir, izdod tieši tādu erroru, bet īsti nesaprotu, kādos gadījumos tad to HAVING lieto? Nekad neesmu tādu manījis un izmantojis arī nē. Link to comment Share on other sites More sharing options...
bubu Posted September 19, 2005 Report Share Posted September 19, 2005 HAVING pēc būtības darbojas tāpat kā WHERE, tikai ar tādu atšķirību, ka WHERE izpildās pirms ORDER/GROUP BY, taču HAVING pēc sasortēšanas/sagrupēšanas. (tas viss ir btw smuki manuālītī uzrakstīts). Link to comment Share on other sites More sharing options...
Analgiins Posted September 19, 2005 Report Share Posted September 19, 2005 (edited) pareiza kaartiiba rakstot querijus ir shada: ... WHERE GROUP BY HAVING ORDER BY ... http://dev.mysql.com/doc/mysql/en/select.html Having izmanto tad, ja vajag atfiltreet peec lauka kas nav tabulaa, bet noteikts SELECT statementaa SELECT CONCAT_WS(' ', first_name, last_name) AS full_name FROM users HAVING full_name = 'Armands Ozols' shajaa gadiijumaa WHERE nevar izmantot, jo lauka full_name nav tabulaa Secinaajums viens: ja vaicaajumaa ir HAVING clause un vajag noteikt cik ierakstu izdot shis vaicaajums tad SELECT COUNT(*) tik vienkaarshi nederess, naaksies vien likt klaat, resp., SELECT COUNT(*) as total, CONCAT_WS(' ', first_name, last_name) AS full_name, a te jau vajag veel GROUP BY, rezultaataa, lai dabuutu COUNT, buus shaads querijs: SELECT COUNT(*) AS total, CONCAT_WS( ' ', first_name, last_name ) AS full_name FROM `user` GROUP BY full_name HAVING full_name = 'Armands Ozols' Edit: neko jau sev posts sanaaca, tjip jautaajums par sesijaam... :) Edited September 19, 2005 by Analgiins Link to comment Share on other sites More sharing options...
bubu Posted September 19, 2005 Report Share Posted September 19, 2005 Ah nu ja, nokļūdījos. Kārtošana vēl nenotika, pareiz. Link to comment Share on other sites More sharing options...
Recommended Posts