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 6627739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:02:57+00:00 2026-05-25T22:02:57+00:00

I have a table called faq . This table consists from fields faq_id ,

  • 0

I have a table called faq. This table consists from fields faq_id,faq_subject.
I have another table called article which consists of article_id,ticket_id,a_body and which stores articles in a specific ticket. Naturally there is also a table “ticket” with fields ticket_id,ticket_number.

I want to retrieve a result table in format:
ticket_number,faq_id,faq_subject.

In order to do this I need to search for faq_id in the article.a_body field using %LIKE% statement.

My question is, how can I do this dynamically such that I return with SQL one result table, which is in format ticket_number,faq_id,faq_subject.

I tried multiple configurations of UNION ALL, LEFT JOIN, LEFT OUTER JOIN statements, but they all return either too many rows, or have different problems.

Is this even possible with MySQL, and is it possible to write an SQL statement which includes @variables and can take care of this?

  • 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-25T22:02:58+00:00Added an answer on May 25, 2026 at 10:02 pm

    First off, that kind of a design is problematic. You have certain data embedded within another column, which is going to cause logic as well as performance problems (since you can’t index the a_body in such a way that it will help the JOIN). If this is a one-time thing then that’s one issue, but otherwise you’re going to have problems with this design.

    Second, consider this example: You’re searching for faq_id #123. You have an article that includes faq_id 4123. You’re going to end up with a false match there. You can embed the faq_id values in the text with some sort of mark-up (for example, [faq_id:123]), but at that point you might as well be saving them off in another table as well.

    The following query should work (I think that MySQL supports CAST, if not then you might need to adjust that).

    SELECT
        T.ticket_number,
        F.faq_id,
        F.faq_subject
    FROM
        Articles A
    INNER JOIN FAQs F ON
        A.a_body LIKE CONCAT('%', F.faq_id, '%')
    INNER JOIN Tickets T ON
        T.ticket_id = A.ticket_id
    

    EDIT: Corrected to use CONCAT

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

Sidebar

Related Questions

I have table called articles_tags which have two columns: article_id tag_id (has_and_belongs_to_many association) (I
I have a table called BlogPost which has a 1-to-many relationship with the Comment
i have a table called category in which i have main category ids and
I have a table called Stock and another called Listed, within the Stock Table
I have table called page which represents every single page in my website. page_id
I have a table called ticket in which I want to swap two rows
I have a table called user_details this table has got morethan 100k user details
I have a table called Shoppings in my SQL db. This one has a
i have table called type which contains data family,individual i want in some pages
I have a table called tblIssueTicket tblIssueTicket contains the fields: TicketID, TicketRequesterID, ApprovalManagerID, RequestDate,

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.