php - MySQL difficulties with AS combined with HAVING -


i have as-related mysql question, when combined having:

this does work (mind "(250) as", second line):

select a.uid, a.name, a.height, a.width, (250) squaresize tx_fach_domain_model_professional a, tx_fach_domain_model_category b, tx_fach_professional_category_mm mm mm.uid_local = a.uid , mm.uid_foreign = 2 having squaresize > 20 order squaresize limit 0 , 4; 

this not work:

select a.uid, a.name, a.height, a.width, (a.height * a.width) squaresize tx_fach_domain_model_professional a, tx_fach_domain_model_category b, tx_fach_professional_category_mm mm mm.uid_local = a.uid , mm.uid_foreign = 2 having squaresize > 20 order squaresize limit 0 , 4; 

the strange thing doesn't give me errors returns 4 of same rows/records, instead of 4 different ones.

pretty clueless here..

above simplified version of real problem.. have (200) in example above, i'm trying measure distance value between longitude , latitude values:

select a.uid, a.name, a.latitute, a.longitute, ( 6371 * acos ( cos ( radians(52.52000659999999) )  * cos( radians( a.latitute ) ) * cos( radians( a.longitute ) -  radians(13.404953999999975) ) + sin ( radians(52.52000659999999) ) * sin(  radians( a.latitute ) ) ) ) distance tx_fach_domain_model_professional a,  tx_fach_domain_model_category b,  tx_fach_professional_category_mm mm mm.uid_local = a.uid ,  mm.uid_foreign = 2 having distance < 20 order distance limit 0 , 4; 

now works long don't use having distance < 20 order distance .. use these, 4 same results, instead of expected 4 different results.

but, in simplified example, i'm having exact same issue.

[solution] did trick , provided functionallity need - proposed @asconfused:

select a.uid, a.name, a.latitute, a.longitute, ( 6371 * acos ( cos ( radians(52.52000659999999) ) * cos( radians( a.latitute ) ) * cos( radians( a.longitute )  radians(13.404953999999975) ) + sin ( radians(52.52000659999999) ) * sin(radians( a.latitute ) ) ) ) distance tx_fach_domain_model_professional join tx_fach_professional_category_mm mm on mm.uid_local = a.uid , mm.uid_foreign = 2 having distance < 20 order distance limit 0 , 4; 

thanks!!!

select a.uid, a.name, a.height, a.width tx_fach_domain_model_professional join tx_fach_professional_category_mm mm on mm.uid_local = a.uid , mm.uid_foreign = 2 limit 0 , 4; 

note squaresize hard coded , useless in top chunk works u say. 250 known front-end


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -