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

  • Home
  • SEARCH
  • 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 8606899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:12:36+00:00 2026-06-12T03:12:36+00:00

Database: MySql 5.5.3 I have a type column in table topic , if the

  • 0

Database: MySql 5.5.3

I have a type column in table topic, if the type is ‘E’ which means there is an entry exist in ‘Event’ Table and it should query “TOPIC_HAS_EVENT” table to get few more colums from the EVENT Table. In the same way if Type is ‘P’ which means there is an entry exist in ‘Poll Table’ and it should query “TOPIC_HAS_POLL” table to get few columns from POLL Table. If the type is null then it should query as usual to get all the rows and their comments from the comment table.

The end results should have all the topics rows of all types (‘E’,’P’, NULL) and their specific columns from other table. If that can accomplish easily then i need to add few more columns as mentioned below

More complex

If type=’E’ have some rows, it should get some more rows such as user information from EVENT_HAS_USER table.

Relationship

Each Topic has Many Comments
Each Topic has One Event
Each Topic has One Poll

EVENT ManyTOMany User

Query so far created. I still need to add ‘type’ column. Please help me with it.

SELECT DISTINCT
        T.TOPIC_GUID, COUNT(*) TOTAL_COMMENTS
    FROM
        CIRCLE C, CIRCLE_HAS_USER CHU, CIRCLE_HAS_TOPIC CHT, TOPIC T
    LEFT JOIN TOPIC_COMMENT TC ON T.TOPIC_GUID = TC.TOPIC_GUID
    WHERE
        CHT.CIRCLE_GUID = C.CIRCLE_GUID
            AND T.TOPIC_GUID < 400000 -- ?
            AND CHT.TOPIC_GUID = T.TOPIC_GUID
            AND CHU.CIRCLE_GUID = C.CIRCLE_GUID
            AND CHU.USER_GUID = 1
            AND CHU.STATUS = 'A'
    GROUP BY T.TOPIC_GUID
    ORDER BY T.LAST_UPDATED_TIMESTAMP DESC
    LIMIT 10 
  • 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-06-12T03:12:37+00:00Added an answer on June 12, 2026 at 3:12 am

    Try this:

    select (case when type = 'type1' then (select field from table1) else (select field from table2) end) as a from table;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In mysql database i have this column called: Name: Date Type: datetime I have
I have a column type money in my sql server database, which is moneyAcumulated
I have a table with a field of type date within a MySQL database.
I have a database in MySQL which have entries of time. There are more
I have a table in a MySQL database with a spatial geometry column of
I have one problem... There is a table in my MySQL database that stores
I have a MYSQL table column of type timestamp and using CURRENT_TIMESTAMP as default
I have mysql database and I want a software which can draw the database
I have mysql database structure like below: CREATE TABLE test ( id int(11) NOT
I have a MySQL database where the table was set up to store the

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.