Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8084185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:42:41+00:00 2026-06-05T17:42:41+00:00

i have a table e.g: CREATE TABLE places (id UNIQUE, name, latitude, longitude) i

  • 0

i have a table e.g:

CREATE TABLE places (id UNIQUE, name, latitude, longitude)

i then loop through my dataset and calculate the distance between users location and my rows, then i display as a list in HTML.

My problem is that i dont know how to sort this list out by ascending order of distance.

Do i save the distance back into the Places table and then do another Select * with an Ascending order…?

can i not do something like select my results, but order them by running a javascript function. basically something like this:

tx.executeSql('select * from places order by ' 
function getdistance(userLat, UserLong, places.latitude, places.longitude)

thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T17:42:43+00:00Added an answer on June 5, 2026 at 5:42 pm

    Because you calling a function that you want in Javascript, you cannot use a function defined external to the database engine as a comparison operator, especially if used via the syntax you provide, where it is being evaluated externally from the query – you need the data to find the value to evaluate the order that the data should be returned. There is no way for the data to get anywhere!

    Instead, you could create a table that has an extra, empty column, and then calculate it via Javascript on the client side, in the HTML. This would allow multiple users to use the application, and you can sort it there.

    OF course, if you are comfortable with doing so, you can create or define a C function in SQLite – I am unfamiliar with the process, but it is described in their documentation here. This would allow you to call it in the SQL itself; Select *, Distance(UserLat, UserLong, places.latitude, places.longitude) as dist from places, uservalues order by dist

    Alternatively, as suggested, you could save the data back into the database, but this will limit concurrency.

    Lastly, you could use MySQL or another database system that is more fully featured.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table: CREATE TABLE siteConfig ( settingName VARCHAR(64) NOT NULL, value VARCHAR(255),
I have a table CREATE TABLE `messages` ( `uid` BIGINT NOT NULL , `mid`
I have a table Create table Country_State_Mapping ( Country nvarchar(max), State nvarchar(max) ) With
I have a table: create table Transactions(Tid int, amt int) With 5 rows: insert
I have this table CREATE TABLE [dbo].[friend_blocked_list]( [subdomain] [varchar](50) NOT NULL, [un] [nvarchar](50) NOT
I have this table CREATE TABLE `codes` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
I have this table: CREATE TABLE `test` ( `ID` int(11) NOT NULL auto_increment, `text`
I have this table: CREATE TABLE `point` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `siteid`
i have this table create table eveniment( + evenimentId bigint not null auto_increment primary
I have a SQLIte database with tables for places and tables for tags, CREATE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.