Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7408439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:55:01+00:00 2026-05-29T05:55:01+00:00

to explain it in very simple terms, I have the following items: ——————————————————————————- id

  • 0

to explain it in very simple terms, I have the following items:

-------------------------------------------------------------------------------
id  Title                              unique_id  type  language  category       
-------------------------------------------------------------------------------
1   Announcement One                        111     1   1         5,6,8
2   Announcement Two                        112     1   1         6
3   Announcement Three                      113     1   1         7
4   Ankundigung Drei                        113     1   2         7,3
5   Announcement Four                       115     1   1         6
6   Announcement of another type            116     2   1         5
7   Another announcement of another type    117     2   1         7
8   Ein anderes ankundigung                 117     2   2         7
9   Subtype 3                               118     3   1         4
10  Tip 3                                   118     3   2         4
-------------------------------------------------------------------------------

The key field here is unique_id (which is a unique announcement id, not primary id).

The announcement list is in English (Language=1) and occasionally there are announcements ALSO in German(Language=2) – as is the case with unique_id 113,117 and 118.

What I want to do is the English users to see the English version of announcements, and German users to see the English version of announcements as well, because English is default for German users as well. However, only in cases where there is ALSO a German version of the announcement, that version should be displayed for German users in German and not in English.

I thought I could achieve this with a simple GROUP BY unique_id and language (asc or desc), but this is throwing very unpredictable results and obviously not working.

Also, I would like to order the results by specified categories, using for example: field (category, 7,6,2) and then the rest of categories to be ordered in ascending order. For categories, if possible, I want to use contains, because one announcement may have several categories in which case I believe contain has to be used for sorting. So, the German user should see the following result:

-------------------------------------------------------------------------------
id  Title                              unique_id  type  language  category       
-------------------------------------------------------------------------------
1   Ankundigung Drei                        113     1   2         7,3
2   Ein anderes ankundigung                 117     2   2         7
3   Announcement One                        111     1   1         5,6,8
4   Announcement Two                        112     1   1         6
5   Announcement Four                       115     1   1         6
6   Tip 3                                   118     3   2         4
7   Announcement of another type            116     2   1         5
-------------------------------------------------------------------------------

This is the first time I’m posting a question on stackoverflow, hopefully I posted a good one 🙂

Thanks in advance

Full SQL Below:

-- Table structure for table `anns`
--

CREATE TABLE IF NOT EXISTS `anns` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(254) NOT NULL,
  `unique_id` int(11) NOT NULL,
  `type` int(11) NOT NULL,
  `language` int(11) NOT NULL,
  `category` varchar(254) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=11 ;

--
-- Dumping data for table `anns`
--

INSERT INTO `anns` (`id`, `title`, `unique_id`, `type`, `language`, `category`) VALUES
(1, 'Announcement One', 111, 1, 1, '2,6,8'),
(2, 'Announcement Two', 112, 1, 1, '6'),
(3, 'Announcement Three', 113, 1, 1, '7'),
(4, 'Ankundigung Drei', 113, 1, 2, '7'),
(5, 'Announcement Five', 115, 1, 1, '6'),
(6, 'Announcement of another type', 116, 2, 1, '6'),
(7, 'Another announcement of another type', 117, 2, 1, '7'),
(8, 'Ein anderes ankundigung', 117, 2, 2, '7'),
(9, 'Subtype 3', 118, 3, 1, '4'),
(10, 'Tip 3', 118, 3, 2, '4');   
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:55:03+00:00Added an answer on May 29, 2026 at 5:55 am

    This might help for retrieving results for German users:

    SELECT *
    FROM (
        SELECT * 
        FROM  `anns` 
        ORDER BY  `announcement_id` ,  `language` DESC
    ) `TA`
    GROUP BY `TA`.`announcement_id`;
    

    I haven’t added the sorting based on categories because I’m not sure on the behaviour. But perhaps you may try putting an ORDER BY after the GROUP BY, like:

    ORDER BY `TA`.`category` DESC"
    

    Hope it helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can some one explain to me in very simple terms what the color media
Can anyone, please, explain to me in very simple terms what a "method" is
I have a very simple query (three where conditions; two equals, one between) from
The title isn't very clear but I'll try to explain. Having this class: class
I'm trying to create a very simple relationship between two objects. Can anybody explain
I have a very simple user model. When I first created it, it had
This should be very simple, but its very frustrating. I have a LinqToSql as
I have a very simple c code: #include<stdio.h> int main() { enum boolean{true,false}; boolean
Can someone explain in simple terms what is Key-Value-Coding and Key-Value-Observing ? Please don't
I have very simple code: List<String> list = new ArrayList<String>(); String a = a;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.