0

I want to know is there any way that I can remove duplicates from my select statement in it's own code.

Example :

I have :

SELECT gl.genre_id , gl.title FROM genre_lang AS gl LEFT JOIN genres AS g ON (gl.genre_id=g.genre_id) WHERE ( gl.lang_code='es_ES' OR gl.lang_code='en_US') ORDER BY gl.title

and my result is something like this :

1      Movies
2      Sport
3      Theathre
3      Drbrbrbr (it should be theathre in spanish)
5      Music

and etc. and the thing that I want to achieve is to show Theathre only in english/spanish?

Is there any way that I can achieve this using sqlite?

2 Answers 2

2

use DISTINCT in your query to select non repetitive records only.

SELECT gl.genre_id , gl.title FROM genre_lang AS gl LEFT JOIN genres AS g ON 
(gl.genre_id=g.genre_id) WHERE ( gl.lang_code='es_ES' OR gl.lang_code='en_US' 
AND gl.genre_id IN (SELECT DISTINCT gl.genre_id FROM genre_lang)) 
ORDER BY gl.title
Sign up to request clarification or add additional context in comments.

1 Comment

actually i had tried this before and it was not working..but after making some changes it's now working properly...so thanks a lot!
1

Try SELECT distinct gl.genre_id , gl.title FROM genre_lang AS gl LEFT JOIN genres AS g ON (gl.genre_id=g.genre_id) WHERE ( gl.lang_code='es_ES' OR gl.lang_code='en_US') ORDER BY gl.title

Comments

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.