List:MySQL and PHP« Previous MessageNext Message »
From:John James Rambo Date:February 21 2012 11:59pm
Subject:Re: Inner Join Question
View as plain text  
Not sure I have the whole picture. Without thinking it all the way
through I can suggest if your comments are dated, replace "comment_date"
with whatever you call your field and try the following:

(NOTE THE LEFT JOIN TOO)


SELECT `customer`.`name`, `comments`.`note`, MAX(comment_date) FROM
customer
LEFT JOIN  `comments` ON `customer`.`id` = `comments`.`customer`
WHERE `customer`.`join_date` >= "2012-01-01 00:00:00"
ORDER BY `customer`.`join_date`
ASC

Gotta run!

JR




On Tue, 2012-02-21 at 18:00 -0500, admin wrote:

> I have an issue where I am joining a table on a table.
> 
> The problem is the table I am joining has more than one row of matching
> data.
> 
>  
> 
> 
> 
> SELECT `customer`.`name`, `comments`.`note` FROM customer
> 
> INNER JOIN  `comments` ON `customer`.`id` = `comments`.`customer`
> 
> WHERE 
> 
> `customer`.`join_date` >= "2012-01-01 00:00:00"
> 
> ORDER BY `customer`.`join_date`
> 
> ASC
> 
>  
> 
> 
> 
> I need to return all the customers and the last note for each customer
> 
> But what I get is a list with the repeat of each customer for each note.
> 
>  
> 
> 
> 

Thread
Inner Join Questionadmin21 Feb
  • Re: Inner Join QuestionJohn James Rambo22 Feb