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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:24:34+00:00 2026-05-28T17:24:34+00:00

I have a website that is running a query off to Mysql when a

  • 0

I have a website that is running a query off to Mysql when a search term is entered. I built a sql statement like this

SELECT * FROM catelogue
WHERE `DEPARTMENT` LIKE 'MUSIC'
AND ( `ARTIST` LIKE '%$theValue%' OR `TITLE` LIKE '%$theValue%' OR 
    `CAT NO.` IN 
    (SELECT `TRACKLISTING CAT NO.`
    FROM tracklisting 
    WHERE `ARTIST` LIKE '%$theValue%' OR `TRACK TITLE` LIKE '%$theValue%'))
    ORDER BY `RELEASEDATE` DESC

It worked great on wamp locally when testing. Now I have uploaded the site to my host and the query seems to be crashing or slowing it down that it doesn’t even load the page.

I redesigned the query to this

SELECT `ARTIST` , `TITLE` , `CAT NO.` , `FORMAT` , `DEPARTMENT` , `SELL`,`IMAGE PATH` 
        FROM catelogue
WHERE `DEPARTMENT` LIKE 'MUSIC'
AND ( `ARTIST` LIKE '%$theValue%' OR `TITLE` LIKE '%$theValue%') 
    ORDER BY `RELEASEDATE` DESC"

As this stands it works great on my host now but I can’t search my tracklisting table. I need to know how to change IN to something that works faster.

The catelogue and tracklisting table are linked by the CAT NO.

Thanks

EDIT

A BIG THANKS TO EVERYONE THAT HELPED

Now onto some bad news. This is the code I’m using now. It doesn’t return any errors but it also doesn’t return any results either

SELECT c.`ARTIST` , c.`TITLE` , c.`CAT NO.` , c.`FORMAT` , c.`DEPARTMENT` , c.`SELL` 
FROM    catelogue c
LEFT JOIN   tracklisting t
        ON  t.`TRACKLISTING CAT NO.` = c.`CAT NO.`
WHERE   'DEPARTMENT' = 'MUSIC'
        AND ((  c.`ARTIST` LIKE '%$theValue%' OR c.`TITLE` LIKE '%$theValue%')
                OR
                (t.`ARTIST` LIKE '%$theValue%' OR t.`TRACK TITLE` LIKE '%$theValue%'))

The tracklisting table doesn’t have all the tracklistings for every entry in the catelogue table. Would that make a difference?

I know in ms access you can setup relationships with tables, but I have been unable to figure out if this can be done in phpmyadmin, do I have to setup a relation between the tables for this to work?

Many Thanks

  • 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-28T17:24:36+00:00Added an answer on May 28, 2026 at 5:24 pm

    Well, I don’t really do PHP so some of your syntax is a little foreign to me but sql is sql and I’ve just copied the bits I’m not used to.

    This should do what you want:

    SELECT  *
    FROM    catelogue c
        LEFT JOIN   tracklisting t
            ON  t.`TRACKLISTING CAT NO.` = c.`CAT NO.`
    WHERE   `DEPARTMENT` = 'MUSIC'
            AND ((  c.'ARTIST' LIKE '%$theValue%' OR c.'TITLE' LIKE '%$theValue%')
                    OR
                    (t.`ARTIST` LIKE '%$theValue%' OR t.`TRACK TITLE` LIKE '%$theValue%'))
    ORDER BY    `RELEASEDATE` DESC
    

    By the way, the field naming in this database is just terrifying IMHO. It would also probably help if you could do some form of full text indexing so that these “contains” LIKE comparisons don’t cause you to do full table scans every time. Just a thought.

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

Sidebar

Related Questions

I have a website that's running on a Windows server and I'd like to
we are running a click-to-call service, my idea is basically like this: website have
I have a website that is running on a server. I want to get
I have an asp.net mvc app running on a local iis website that is
I have a website running a basic ASP.NET application that is mostly used from
I have an existing website running on IIS6 that has only static HTML pages.
I have a website that does inserts into this table below. I need to
I have a website running on a Windows 2008 R2 server, using a SQL
Currently I'm running several websites that have several (branded) duplicates each, in the same
So basically I have website that has names of cities that can be checked

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.