0

Here is my query:

SELECT
  CASE
      WHEN hbn.users.showDistance = 'T' 
      THEN hbn.distance(u2.lat, u2.lon, hbn.users.lat, hbn,users,lon)
    ELSE 0
  END as distance,
hbn.users.id,
hbn.users.username,
From hbn.users,
(select hbn.users.lat, hbn.users.lon from hbn.users where hbn.users.id = '1') AS u2
where hbn.users.Id = '8';

This does not work! I need to use output of the second select statement as input for distance() function.

3
  • FYI, It looks like you have conflicting where clauses between your main query and your subquery hbn.users.id='1' and hbn.users.id='8'. I don't know if that's causing your problem though Commented Aug 27, 2011 at 20:11
  • Please explain what doesn't work about this query. Does it not even run? Does it just not give you the results you expect? Also, what results ****DO**** you expect? Commented Aug 27, 2011 at 20:12
  • Please post what is the error message you're having. In your CASE statement if the 'showDistance' is not equal to 'T', then you'll have the column 0. I'm not sure that's possible. And I also reinforce what jadarnel27 said. Commented Aug 27, 2011 at 20:37

1 Answer 1

1

It looks like you have commas instead of full-stops in the last parameter to hbn.distance?

Sign up to request clarification or add additional context in comments.

1 Comment

Also, is the comma after hbn.users.username valid?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.