unknown column in having clause
See original GitHub issueIssue type:
[ ] question [ ] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[+ ] mysql
/ mariadb
[ ] oracle
[ ] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[ ] latest
[ ] @next
[+ ] 0.2.18
(or put your version here)
Steps to reproduce or a small repository showing the problem:
const queryBuilder = this.restaurantRepository.createQueryBuilder('brands')
.addSelect('brands.*, deliveryInfos.*, businessHours.*')
.addSelect(`( 6371 * acos( cos( radians(${lat}) ) * cos( radians( brands.latitude ) ) * cos( radians( brands.longitude ) - radians(${lng}) ) + sin( radians(${lat}) ) * sin( radians( latitude ) ) ) )`,'distance')
.leftJoinAndSelect('brands.deliveryInfos','deliveryInfos')
.leftJoinAndSelect('brands.businessHours','businessHours')
.where('brands.active=1 AND brands.deleted=0')
.having('distance < 5')
.orderBy('brands.created_at')
I got unknown column from this code block. Any suggestion?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6
Top Results From Across the Web
Unknown column in 'having clause' - mysql
The SQL standard requires that HAVING must reference only columns in the GROUP BY clause or columns used in aggregate functions.
Read more >mysql 5.7 - Unknown column in Having Clause
Although the objective has been achieved by using Where Clause before Group By, but this error is still bothering. Any help would be...
Read more >103961: Error: "Unknown column 'foo' in 'having clause' ...
If the HAVING clause refers to a column that is ambiguous, a warning occurs. In the following statement, col2 is ambiguous because it...
Read more >MySQL : Unknown column in 'having clause' - YouTube
MySQL : Unknown column in 'having clause ' [ Beautify Your Computer : https://www.hows.tech/p/recommended.html ] MySQL : Unknown column in ...
Read more >MySQL Operational Error: "Unknown column 'x' in 'having ...
Based on this model, I perform the following query in a MySQL backend. x = 5 expr = Sum(F('f2')) o = Example.objects.using('mysql') q...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Any update on this issue? Am having issues with this
@sahibhuseyn I think the
distance
alias you are using for your calculation is by default out of the scope ofbrands
entity and that is causing the issue. I had similar case and when I used.getRawMany()
method at the end, the error was gone.