How to get routing table elements in route list

Hello guys,
I wanted to know how to get the element routing table from the route list.
I tried something like this but it does not work:

:local a [/ip/route/get [find where gateway=x.x.x.x] routing-table];

Another problem is that I do not want the routing table “main” but I am using the same gateways for two list items.
Here a picture for better understanding.

Any help would be appreciated:)

Your syntax is wrong, try:
:local a [/ip/route/get [find where gateway=x.x.x.x and routing-table=yyyy];

I forgot to say: I want to find out the the name of the routing-table over the route list. The only information i have is the gateway and it can not be the main-routing table.

then use routing-table!=main
I don’t see the problem…

no, the syntax is right, it want know the routing-table, if must be specified in find that mean that is already knowed…



This syntax is correct on v7(.7), but if more than one gateway is present, get returns an error because it cannot handle the array.

:local rt [/ip/route get [find where gateway=11.22.33.44 and routing-table!=main] routing-table]

This do not do errors if multiple routes with same gateway (and not on main routing table) exist

/ip/route
{
    :local gway   1.2.3.4
    :local search [find where gateway=$gway and routing-table!=main]
    :local result ({})
    :foreach index in=$search do={
        :set $result ($result,[get $index routing-table])
    }
    :put $result
}

Thank you very much. This is working good.