N
N
nepster-web2014-12-17 01:49:21
MySQL
nepster-web, 2014-12-17 01:49:21

How to make a selection depending on the language?

I am making a multilingual resource and there is a translation table.
When fetching data, I use the following query:

SELECT * FROM `products_properties_translates` WHERE lang_id = '2' AND (`property_id` IN ('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'));

Everything is working well.
Now there is a task to do the following:
If there is no translation, then use the default translation (lang_id = '1' )
Please tell me how this check can be organized in the request?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Yakovenko, 2014-12-17
@Xazzzi

'lang_id' IN (required, default) ORDER BY 'lang_id' DESC LIMIT 1
Default is assumed to be less than desired.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question