PDA

View Full Version : display one image for each headline?


student101
11-21-2008, 07:22 AM
I have two tables - tbl1 and tblimages
tbl1 is the parent
tblimages is the child

tbl1 has 10 records
tblimages has 20 records 2 images for each record in tbl1

All I would like is to display one image for each headline
SELECT DISTINCT
tbl1.tbl1id, tbl1.headline, tblimages.tbl1id
FROM
tbl1
Inner Join tblimages ON tbl1.tbl1id = tblimages.tbl1id

OR
SELECT DISTINCT
tbl1.tbl1id, tbl1.headline, tblimages.tbl1id
FROM
tbl1 ,tblimages
WHERE
tbl1.tbl1id = tblimages.tbl1id


Cheers

davidj
11-21-2008, 07:54 AM
so tblimages having 2 images

you want to reduce this to 1 image instead yes?

is your join working

student101
11-21-2008, 08:00 AM
Not to reduce as in remove, just display 1 image per headline
Something like;
Show Headline with linked Image
next Headline with linked Image
and so on...

With or without join it works in dsiplaying the distinct record.

Just got it! group by tbl1.tbl1id
Without DISTINCT and now I never have to use a nested repeated tool ever again.