..... If the market makers bid at the same price as the ECN, who has priority? That I don't know.
I am answering my own question. More information about this. The following is my understanding. Correct me if I am wrong.
On Nasdaq, there are multiple market makers (usually) for a given stock. They all can buy/sell the given stock. Other participants can trade with the market makers (via SelectNet), or trade with other participants via different ECN's (ARCA, Instanet, etc.).
In theory, no one particular market maker controls the price of a given stock. Market makers compete with each others to trade that given stock and each tries to make profit for his/her firm. So the price (bid/ask) fluctuates. Market makers for a given stock are required by regulations to make a 2-way market. Which means during regular sessions, they must provide a bid and an ask for that stock.
The current best bid and best ask prices are known as the "inside market". e.g. CSCO bid 16.27, ask 16.33. There might be multiple market makers offering the same bid or the same ask. Typically though, market makers will mark-up the price more than the inside market spread. e.g. GSCO may bid CSCO at 16.27. But they won't sell CSCO at 16.33. They would sell CSCO at 16.40. MILO may bid CSCO at 16.20 and sell at 16.33. etc..
Now... limit price orders always get queued up on the ECNs at different price levels. e.g. there may be 200 shares bidding at 16.27, 500 shares bidding at 16.26, 300 shares bidding at 16.25, etc.. And there might be 400 shares asking at 16.33, 300 shares asking at 16.34, 100 shares asking at 16.35, etc.. These orders are in the queue to be executed in a First-In-First-Out fashion. If traderA bids 200 shares of CSCO at 16.27, and traderB bids 500 shares of CSCO also at 16.27, traderA's 200 shares at that price will get filled first, then the rest of the shares for traderB - provided that the market price has not run away. At each inside bid/ask level, only the limit orders on the ECN at that price will become executable. e.g. if the best current bid price for CSCO from a market maker is at 16.27, then the limit orders at 16.27 on the ECNs will become executable. Stocks can be sold from one ECN participant to another at 16.27.
If someone wants to sell 100 shares of CSCO at 16.27, who will get his stock? The market maker or the ECN participant who is bidding at 16.27? Well... that depends on how such an order is routed. If that order to sell is routed through SelectNet to target a particular market maker, then the stock will go to the market maker. If that order is routed to an ECN, then the ECN participant will get that order. Using a Direct Access Platform, you can control if you want your order to go to SelectNet or an ECN.
If you place a market order to sell your 100 shares of CSCO, then it will depend on the routing logic used by that trading platform in what sequence to route your order to and how long it will wait before going to the second choice. If you use an Internet browser base kind of platform, your broker will sell your order flow to the market maker who pays them kick-backs to fill your order. (And they will eat you because you just wrote them a blank check.)