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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:13:48+00:00 2026-05-27T16:13:48+00:00

I have a query that returns results related to items that match a specific

  • 0

I have a query that returns results related to items that match a specific category…

There are 3 mysql tables that results to this, items, categories and item_categories.

These i assume are self explanatory, but the latter, is a linking table that links any specific item to any specific category, using a match of id’s.

The items table contains one row, with an id value of 1.

The categories table is filled with 15 rows, with id values of 1-15.

the item_categories table contains one row, the item_id value is 1 and the category_id value is 5.

This is the mysql query in its php form:

$catResultQuery = "
        SELECT i.id, name, price
        FROM items i
        INNER JOIN item_categories
            ON i.id = item_id
        INNER JOIN categories c
            ON category_id = c.id
        WHERE MATCH (c.id)
        AGAINST ('{$_SESSION['input']}' IN BOOLEAN MODE)
        ORDER BY name
";

The session variable has a value of 5, but for some reason, this query displays a 0 result set.

Even when i run the query in php myadmin, it returns 0 rows.

And i am confused, because in my head, the logic behind all of this seems fairly simple, but for some reason i get 0? Does anyone have any idea where i have gone wrong with this?

Any advice and input would be greatly appreciated, thank you!!

  • 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-27T16:13:48+00:00Added an answer on May 27, 2026 at 4:13 pm

    Ok, I see now that you’re building the SQL dynamically. If that’s the case, then this should work:

    SELECT i.id, name, price
        FROM items i
        INNER JOIN item_categories
            ON i.id = item_id
        INNER JOIN categories c
            ON category_id = c.id
        WHERE c.id
        IN ('{$_SESSION['input']}')
        ORDER BY name
    

    Just make sure ‘{$_SESSION[‘input’]}’ is comma delimited and be aware that this carries the risk of SQL injection because you’re constructing the SQL on the fly.

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

Sidebar

Related Questions

I'm running an MySQL query that returns results based on location. However I have
I have a method that basically returns the results of a mysql query. public
i have a query that returns some users related to a specific user (Bob).
I have a MySQL query that returns a result with a single column of
I have a query that returns data with group category and some details like
I currently have a query that returns results based on a dynamic set of
I currently have a SQL query that returns results based on a dynamic number
I have a query that returns a result set similar to the one below:
I have a query that returns a string, as well as an escape character
i have a query that returns rows that i want, e.g. QuestionID QuestionTitle UpVotes

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.