1

I have two table's table as follows:

Names :-

id firstname lastname, address, phone

Now, i have another table which contains lets say location data for person's in first table

Location :-

id latitude, longitude

now , i have to select, firstname, latitude, longitude only using sql/sqlite query.

Currently, my query is :-

  Names nameTable INNER JOIN Location locationTable ON nameTable .id =locationTable .id WHERE nameTable .id=12

This query i use in android sqlite and it returns me full table.

I want specific columns only to increase performance. Can anyone help me with the query ?

1
  • SELECT Names INNER JOIN Location ON Names.id = Locations.id WHERE Names.id = 12 should work, if id is UNIQUE. Commented Oct 29, 2014 at 9:22

1 Answer 1

4

This select statement should work:

SELECT n.firstname, l.latitude, l.longitude FROM Names n JOIN Location l ON n.id = l.id WHERE n.id=12

I usually use SQLLiteBrowser (or something similar) which allows you to load your database and to execute SQL queries on it. This way you can test your statements befor putting them unto you code.

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

1 Comment

If this answer helped you to solve your problem please accept the answer! Thank you very much

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.