|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to only display one image based on this query?
Code:
SELECT DISTINCT tbl1.tbl1id, tbl1.headline, tblimages.tbl1id FROM tbl1 Inner Join tblimages ON tbl1.tbl1id = tblimages.tbl1id OR Code:
SELECT DISTINCT tbl1.tbl1id, tbl1.headline, tblimages.tbl1id FROM tbl1 ,tblimages WHERE tbl1.tbl1id = tblimages.tbl1id As soon as I add tblimages.imagename it shows all 20 records and not the distinct records or one of. What I mean; 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 based on each headline. Cheers
__________________
Amateurs ... Built the ark. Professionals ... Built the Titanic. Last edited by student101 : November 21st, 2008 at 01:14 AM. |
|
#2
|
|||
|
|||
|
you could use limit to get only one result row:
Code:
SELECT someColumn1, someColumn2
FROM TableName
INNER JOIN OtherTable ON TableName.ID=OtherTable.ID
LIMIT 1
limit works by using "offset, count" so if you wanted the 5th row, you could use LIMIT 5,1 or if you wanted numbers 11-15 you can do LIMIT 11,5 which would pull back 5 rows starting at 11. |
|
#3
|
|||
|
|||
|
That is interesting, thank you.
I only needed one image per headline... Code:
group by tbl1.tbl1id Without DISTINCT and now I never have to use a nested repeated tool ever again. |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > Only display one image based on query? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|