0

In iOS i am using sqllite , i have create database with two tables one is for person and second is for person images, i want to get person info with any one image BUT my query is return all image with repeat person id please help me here is my query

SELECT  person.id,person.name,person.date,allimages.imagepath,allimages.personid FROM Person INNER JOIN allimages 
ON Person.id=allimages.personid 
ORDER BY Person.ID

please share your valuable knowledge . In short i don't want to repeat person id

1 Answers1

0

Assuming that "any one image" means "some random image", this will do what you want:

SELECT id,
       name,
       date,
       (SELECT imagepath
        FROM allimages
        WHERE personid = Person.id
        LIMIT 1
       ) AS imagepath
FROM Person
ORDER BY id
CL.
  • 173,858
  • 17
  • 217
  • 259