Jump to content
php.lv forumi

sessijas_atkal


nemec

Recommended Posts

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 by Analgiins
Link to comment
Share on other sites

×
×
  • Create New...