Gossamer Forum
Home : Products : DBMan SQL : Discussion :

SELECT QUESTION

Quote Reply
SELECT QUESTION
Hi,

does anyone know how I do the following?:

I have a table where the data of 30.000 products are stored. Also a StoreID is stored for every product.

Then I have a table with StoreNames,LogoURL,etc.

Now I want to display the right Store-Name and Logo for each Product based on the StoreID (StoreID is NOT a Primary Key in the tables products and stores).

It should be something like:

[<%ProductName%>] [<%ProductURL%>] [Display Logo and Shopname: Select Logo,Storename FROM stores WHERE stores.StoreID = products.StoreID]

I hope someone could help me.

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.
Quote Reply
Re: [ManuGermany] SELECT QUESTION In reply to
Hi Manu,

As you mentioned that StoreID is not a primary key in 'stores' table, so you cannot use the 'queries' feature which is very useful for relational database.

In your case, you can create a global template which will get product's information:

sub {
my $tags = GT::Template->tags;
my $record = $tags->{results}[$tags->{row_num}-1];
my $store_id = $record->{StoreID};
my $info = $tags->{home}->{sql}->table('stores')->get({ StoreID => $store_id });
return %$info;
}

Change search_results.html like:

<%loop results%>
<%global_template_name%>
......<%StoreNames%> <%LogoURL%>
<%endloop%>

P.s: I think that you should use the 'queries' feature which is much faster than this way.

TheStone.

B.

Last edited by:

TheStone: Jan 7, 2003, 10:31 AM
Quote Reply
Re: [TheStone] SELECT QUESTION In reply to
Hi, thanks for your help!

but the code above should be:

....

return $info;
}


(without the %)

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.