Question: I have two tables. One is the "probe" and the other "transcript". 

Probe table: "probe"

ProbeID-------TranscriptID----

```
2655       4555555
2600       5454542
2600       4543234
2344       5659595

```

...etc

Transcript table: "transcript"

TranscriptID----Location----

```
7896736      chr1
5454542      chr1

```

...etc

I need to find out how many transcripts per chromosome? AND How many probes per chromosome?

```
SELECT COUNT(*) 
FROM transcript

```

= '28869' #Above I think gives me the transcripts per chromosome (i.e. location).

I need help with answering the second part (and first, if its wrong). I am assuming I need to use the `JOIN` clause. 

Thank you.

Answer: 
I did this exact thing on a client site. I re-used the same product grid across the entire site and it was 100% DRY. I used the dev branch of Stash and used the new embed feature. While regular embeds are always an option that *work*, Stash embeds are more efficient and more powerful.

The real difference is how you pass variables, and when the embed is parsed. With stash embeds can be used inside a looping tag, and parse the data just once. (Where as regular embeds get parsed with each iteration of the loop.)

Here is a Gist I posted a while back for another user on Twitter.
<https://gist.github.com/2950536>

Note, the example represents multiple files and code blocks, or I would just post here. IMO, it would make this post hard to follow and read if I posted it here. Essentially it follows a modified template partials approach.

More information on template partials.
<http://eeinsider.com/blog/ee-podcast-stash-template-partials/>

But to more directly answer the question of, "How does one replace embed variables with Stash?". The solution is rather simple and based on core programming concepts of "setters" and "getters".The theory is, if one sets a variable it can be retrieved at any later point in the template. The trick is settings the variables before the getters are parsed.

```
{exp:stash:set}

    {stash:page_content}

        {exp:channel:entries channel="your-channel"}

            {stash:your_var_1}Some value 1{/stash:your_var_1}
            {stash:your_var_2}Some value 2{/stash:your_var_2}
            {stash:your_var_3}Some value 3{/stash:your_var_3}
            {stash:your_var_4}Some value 4{/stash:your_var_4}

            {stash:embed name="your-template" process="start"}

        {/exp:channel:entries}

    {/stash:page_content}

{/exp:stash:set}

{stash:embed name="header" process="end"}

```

That's where the *process* parameter comes into play. This will allow you to embed your template *before* the entries loop is ran, and to embed the header which would contain the site wrapper and output the page content. Once you get the hang of it, it becomes really powerful and makes your sites so much cleaner.
You can either use embeds or possibly stash depending on what you are trying to pass. 

<https://github.com/croxton/Stash>