Mysql - Trying to get just one result back in a union -


What I'm trying to do is query the database that all sites selected for my site are all based on the channel Find channels. Therefore there is a table in DB for all channels, a second table in which all the channel contents are kept, the content that is assigned on the basis of that language. So say I have a listing with features like available in English and Spanish in a channel, so that the same channel from both the main channel table, there are two entries will not be recorded, then channel_local table Channel Table ID but Having the English version of the channel and the Spanish version of the second channel. How can I query the main channel list and I can get the language version of the channel based on the chosen went current language for the site Canl_lokl Table I, but if you do not get any results site of a query in the default language Found all the default within? I thought a union would work, but it would be both an English and a Spanish version. Query:

  SELECT * FROM (where select channel_local.channelid, channel_local.channelname, channel_local channel.id = Join channel.channelorder inner channel channel_local.channelid channel.active = 1 and the channel_local.languageid = {} currentlanguageid UNION selection channel_local.channelid, channel_local.channelname, including channel.id = channel_local.channelid channel_local on channel.channelorder inside the channels where channel.active = 1 and channel_local.languageid = {defaultlanguageid}) The channel 1   

results are:

  • Channel 1 English version
  • 1 Spanish version of the channel
  • Channel 2
  • Channel 2 organ
    • If current language is Spanish, then I would like the result:

    • Channel 1 Spanish version
    • Channel 2 English version (because there is no Spanish version for Channel 2)

      < after div class = "join text" itemprop = "text">

        select (select * channel_local.channelid, channel_local.channelname, channel channel.id = channel_local.channelid channel_local inner channel.channelorder Where channel.active = 1 and channel_local.languageid = {} currentlanguageid union selection channel_local.channelid, channel _local.channelname, including channel_local on channel.channelorder inner channel channels Kid = Channel_localkchannelid where channel.active = 1 and channel_local.languageid = {defaultlanguageid}) channels.channel_local.channelid as channels GROUP    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -