vapor
May 5, 2009, 10:24am
1
I am using INNER JOIN and it is supposed to return more than one results
but it only returns first element.
How do I get all elements in an array?
Also, in the same query I am using another INNER JOIN that is supposed
to return one value only which is does.
Thanks.
vapor
May 5, 2009, 1:41pm
2
It’s hard to help you if you don’t show any code.
Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/
(en)
On Tue, May 5, 2009 at 5:24 AM, Vapor …
vapor
May 5, 2009, 1:48pm
3
MaurÃcio Linhares wrote:
It’s hard to help you if you don’t show any code.
@dest = Destination.find_by_id(params[:id], :joins => “INNER JOIN cities
ON cities.id = city_id
INNER JOIN destination_images ON destination_images.destination_id =
destinations.id AND destination_images.is_primary_photo = 1
INNER JOIN destination_tags ON destination_tags.destination_id =
destinations.id”,
:select => ‘destinations.*, cities.name as city_name,
destination_images.url as image_url, destination_tags.tag_id as
tag_id_list’ )
pretty messy though!
vapor
May 5, 2009, 1:51pm
4
Vapor … wrote:
MaurÃcio Linhares wrote:
It’s hard to help you if you don’t show any code.
@dest = Destination.find_by_id(params[:id], :joins => “INNER JOIN cities
ON cities.id = city_id
INNER JOIN destination_images ON destination_images.destination_id =
destinations.id AND destination_images.is_primary_photo = 1
INNER JOIN destination_tags ON destination_tags.destination_id =
destinations.id”,
:select => ‘destinations.*, cities.name as city_name,
destination_images.url as image_url, destination_tags.tag_id as
tag_id_list’ )
tag_id_list is supposed to return an array
vapor
May 5, 2009, 1:59pm
5
MaurÃcio Linhares wrote:
This query is never going to return an array, it’s going o return a
single row (by the params[:id]) with the joined relations.
Yeah, any help would be appreciated
vapor
May 5, 2009, 1:57pm
6
This query is never going to return an array, it’s going o return a
single row (by the params[:id]) with the joined relations.
Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/
(en)
On Tue, May 5, 2009 at 8:51 AM, Vapor …
vapor
May 5, 2009, 3:02pm
7
First you need to explain what you do want returned and your database
structure.
Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/
(en)
On Tue, May 5, 2009 at 8:59 AM, Vapor …