Mysql where子句中的SQL查询面临问题

Mysql where子句中的SQL查询面临问题,mysql,sql,Mysql,Sql,我在MySQL上有以下数据库方案,我想检索一个特定id的所有元素 例如,我想检索城市、类别、与优惠券链接的部门以及其他字段。 我编写了下面的SQL查询,但不幸的是无法得到所需的结果 SELECT cc_coupon.id_coupon as idCoupon, cc_coupon.condition_coupon, cc_coupon.description, cc_coupon.type_coupon, cc_coupo

我在MySQL上有以下数据库方案,我想检索一个特定id的所有元素

例如,我想检索城市、类别、与优惠券链接的部门以及其他字段。 我编写了下面的SQL查询,但不幸的是无法得到所需的结果

SELECT  cc_coupon.id_coupon as idCoupon, 
        cc_coupon.condition_coupon, 
        cc_coupon.description, 
        cc_coupon.type_coupon, 
        cc_coupon_by_categorie.id_categorie, 
        cc_categorie.categorie as category, 
        cc_annonceur.raison_sociale, 
        cc_coupon_active_in_cities.id_ville as ville_slug, 
        cc_villes_france.ville_slug, 
        cc_villes_france.ville_nom_departement,
        cc_villes_france.ville_departement
FROM cc_coupon, 
     cc_coupon_by_categorie, 
     cc_categorie, 
     cc_annonceur, 
     cc_coupon_active_in_cities, 
     cc_coupon_active_in_departments,
     cc_villes_france
WHERE cc_coupon.id_coupon = cc_coupon_by_categorie.id_coupon 
    and cc_categorie.id_categorie = cc_coupon_by_categorie.id_categorie 
    and cc_coupon.id_annonceur = cc_annonceur.id_annonceur
    and cc_coupon.id_coupon = cc_coupon_active_in_cities.id_coupon 
    and cc_villes_france.id_ville = cc_coupon_active_in_cities.id_ville
    and cc_villes_france.ville_departement = cc_coupon_active_in_departments.ville_departement
    and cc_coupon.id_coupon = 1 
    and cc_coupon_active_in_cities.id_coupon = 1 
    and cc_coupon_active_in_departments.id_coupon = 1

谢谢你的帮助

我认为在连接两个表时,应该使用on而不是where。当您要指定其他条件时,请使用where子句。

那么您的结果有什么问题?只要一个提示、样本数据、当前结果和想要的结果就可以给我们一个线索!事实上,通过这个查询,我没有得到任何结果。删除条件,一次一个,然后看看会发生什么。首先尝试使用=1。我期望得到的结果是,将显示的行数乘以链接城市和具有id_优惠券、id_类别、类别、RS、id_ville、ville_name、ville_DepartmentsStart的城市数,并将其与两个表进行较小的联接,然后逐步扩展,直到到达最终查询!