Query question:

  • Thread starter Thread starter gz
  • Start date Start date
G

gz

I have a joint query:

SELECT Clients.CompID, Clients.CompName, Advertises.ItemTitle
FROM Clients INNER JOIN Advertises ON Clients.CompID = Advertises.CompID;

This query will show repeated CompID, if the CompID has more than one
Advertise.
I need to modify this query to let the CompID only show once no matter how
many Advertise it has.

How can I do this? Any help?

Thanks!
 
If there are many ItemTitles related to the Client's CompID, which one would
you want to show. Remeber that Query returns rows so if you you want to
show multiple ItemsTitles, some other Fields will be repeated due to the
join.
 
Thanks for reply. Its does not matter which ItemTitles will be shown. May be
the first one or the smallest AdID (which is auto number field) of the
Advertises talble for the CompID.
 
In this case, try a GROUP BY Query:

SELECT Clients.CompID, Clients.CompName,
First(Advertises.ItemTitle) As FirstOfItemTitle
FROM Clients INNER JOIN Advertises
ON Clients.CompID = Advertises.CompID
GROUP BY Clients.CompID, Clients.CompName;
 
Back
Top