Mysql
 sql >> Datenbank >  >> RDS >> Mysql

Mysql select with Where und default if where Bedingung nicht vorhanden

Sowas in der Art. Ich kenne Ihr genaues Schema nicht:

select 
   p.id, 
   if(IS NULL d2.description, d1.description, d2.description ) `description`
 from product p
 join productDetails d1
   on product.id = productDetails.product_id
      and
   productDetails.language = 'default_lang'
 left join productDetails d2
   on product.id = productDetails.product_id 
      and
   productDetails.language = 'en'