sql >> Database teknologi >  >> RDS >> Mysql

MySQL attributdatabase

Brug venligst ikke implicit joinsyntaks. Et andet sæt joins er nødvendigt for at få en anden attribut.

SELECT upa1.value, upa2.value, up1.status, u1.status 
  FROM product p
    /* These joins get attribute/value for 'username' attribute */
    INNER JOIN product_attribute pa1
      ON p.product_id = pa1.product_id
        AND pa1.attribute_name = 'username'
    INNER JOIN user_product_attribute upa1
      ON pa1.product_attribute_id = upa1.product_attribute_id
    INNER JOIN user_product up1
      ON upa1.user_product_id = up1.user_product_id
    INNER JOIN user u1
      ON up1.user_id = u1.user_id 
    /* These joins get attribute/value for 'domain' attribute */  
    INNER JOIN user_product_attribute upa2 
      ON upa1.user_product_id = upa2.user_product_id
    INNER JOIN product_attribute pa2
      ON upa2.product_attribute_id = pa2.product_attribute_id            
        AND pa2.attribute_name = 'domain'
  WHERE p.product_name = 'email'


  1. PHP MySQLi multi_query forberedt erklæring

  2. Er firkantede parenteser gyldige i en SQL-forespørgsel?

  3. Kaldning af en lagret procedure inden for en lagret procedure

  4. Optimer GROUP BY-forespørgsel for at hente seneste række pr. bruger