tags:

views:

35

answers:

1

Is it possible to have a query such as the following:

SELECT
@threadIDvar = `threads`.`id` AS `threadID`,
(SELECT `posts`.`timeDate` FROM `posts` WHERE `posts`.`threadID` = @threadIDvar) AS `postDate`
FROM `threads`
INNER JOIN `posts` ON `posts`.`threadID` = `threads`.`id`
WHERE `threads`.`boardID` = 1

I have tried it but I get @threadID returned as NULL and consequently postDate also as NULL.

How do I get the variable @threadIDvar to be filled with the returned threadID?

+1  A: 

Don't forget the := for user variable , @threadIDvar:=threads.id

Patrick
Ah... That I forgot... Thank you :)
JD