阅读背景:

如何根据列条目的任意列表返回mysql行?

来源:互联网 

I have a database with product UPC numbers and vendor ID numbers. It's possible for multiple vendors to supply the same products, so a simple query against UPC can (and often does) return multiple rows. However, there is a vendor preference list (because vendors sell the same product at different prices), and my goal is to return the product entry from the most preferred vendor. In short, given five vendors numbered 1 through 5, the preferred vendor list may be $vendors = array(5,3,1,2,4);. Different users have different preference lists. Therefore, right now I'm creating the preferred vendor list, looping through queries up to five (actually 83) times, and stopping the first time a query returns a row. It's very slow. Is there a single MySQL command that accepts (sorts by) an arbitrary list of column values and, using "LIMIT 1", return only the first found value?I have a database with product UPC numbers and




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: