Query help #46
Replies: 4 comments 1 reply
-
Hey there, in general like this: Place::query()
->crossJoin('tour_tracks')
->stWhere(ST::DWithin(....))
->groupBy('places.id')
->get(); I just looked over all the implemented ST functions and it seems, that we haven't implemented ST_DWithin yet. |
Beta Was this translation helpful? Give feedback.
-
Hey again, we just updated our package and included all the missing Distance Relationships. Place::query()
->crossJoin('tour_tracks')
->stWhere(ST::dWithinGeography('places.location', 'tour_tracks.location', 10000))
->groupBy('places.id')
->get(); You might also archive the same behaviour using the dwithin as join condition: Place::query()
->join('tour_tracks', function($join) {
$join->stWhere(ST::dWithinGeography('places.location', 'tour_tracks.location', 10000))
})
->groupBy('places.id')
->get(); Note If you just want to retrieve all Places that are within at least 10000m of a tour_track, you can use it within a subquery: Place::query()
->whereIn('id', function($sub) {
$sub
->select('places.id')
->from('places')
->join('tour_tracks', function($join) {
$join->stWhere(ST::dWithinGeography('places.location', 'tour_tracks.location', 10000))
});
})
->get(); |
Beta Was this translation helpful? Give feedback.
-
Thanks for getting these changes in so fast. Unfortunately it's not working correctly quite yet. I am only getting rows that have location = null. Here my 2 queries that I test 1:1
|
Beta Was this translation helpful? Give feedback.
-
yes, that did the trick. Very nice. Thanks for the quick turnaround! |
Beta Was this translation helpful? Give feedback.
-
How would I write the following query with your eloquent syntax?
Beta Was this translation helpful? Give feedback.
All reactions