One to many left join

Hi Wapplers

struggling with a server connect. I have a one to many table, the right table can also be null (no records).

So i have a table “jobs” and a table of “job_photos”. Jobs is a table with 1 row. job_photos can contain NO photos or many photos.

On my App side I have a repeat region that loops through jobs showing the jobs, and what I want it to do is then show 1 image from job_photos if it has a photo.

I have it showing a photo and if no photo it shows “no image uploaded”. But, if jobs_photo has say 3 photos uploaded then I get 3 rows in my page.

I need a top 1 job_photos type thing to just give me one image.

Not sure if its possible in wappler. If not I will have to add a column to the job_photo of “show this image” but then dont know how to populate that field if someone drags and drops multiple images when they do their upload.

Thanks
Darren

Hi Darren,

There is a top formatter for repeat regions. Put your image in a repeat region (Like I think you have now if I understand). And apply the ‘top’’ formatter to the expression.

unfortunately if I put the Top on the repeat condition I only get one job record on the page, I want the list of jobs, but just ONE photo per job.
thanks
Darren

Yes, you would use nested repeat regions. One repeat for your jobs and within that repeat another repeat for images with top applied to it.

thanks, solved, couldnt get a top on the 2nd repeat as option never appeared but it worked anyway, just getting one job line even if it has multi photos so all good :slight_smile: thanks everyone

1 Like