mysql:通过传递多个值来获取多个表中的数据组合

时间:2015-06-23 06:14:10

标签: mysql database sails.js mysql-workbench rdbms

在我的数据库中。我有三个表类别,位置和分类。

我在每个列的数组中都有一些值

 location:['delhi','mumbai','goa','chennai']
 Category:['Teacher','Student','Managment']
 classification:['expert','normal']

现在我想从表中获取数据组合。

我正在使用存储过程。

以前我只有一个地点,一个类别和一个分类,所以我用这个:

FROM user u1, serviceprovider s1, city c1 
WHERE s1.userId = u1.id 
  AND c1.cityId = s1.city
  AND s1.serviceProviderId IN 
      (SELECT DISTINCT serviceprovidecategoryr_cl AS serviceProviderId 
       FROM Db.serviceprovider_cl__serviceproviderclassification_classification t1
       INNER JOIN Db.location_servicelocation__serviceprovider_locationid t2 ON t1.serviceprovider_cl = t2.serviceprovider_locationId
       INNER JOIN Db.category_serviceprovidercategory__serviceprovider_category t3 ON t2.serviceprovider_locationId = t3.serviceprovider_category
       WHERE 
           t1.serviceproviderclassification_classification IN 
              (SELECT serviceProviderClassificationId 
               FROM serviceProviderClassification sp 
               WHERE sp.name = classification)
           AND t2.location_serviceLocation IN 
               (SELECT locationId 
                FROM location 
                WHERE shortAddress = location)
           AND t3.category_serviceProviderCategory IN 
               (SELECT categoryId 
                FROM category 
                WHERE categoryName = category)
);
END

但是现在我获得了多个值,以便如何修改这个存储过程?

如果还有其他好方法可以做到这一点。

请帮忙......

0 个答案:

没有答案