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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T08:22:12+00:00 2026-05-17T08:22:12+00:00

Here’s a SQL query that I slightly scrubbed (just the column/table/database names). I kept

  • 0

Here’s a SQL query that I slightly scrubbed (just the column/table/database names). I kept the structure the same as production. This is a query taken from my MySQL log.

SELECT      master.pk AS pk,
            master.vendor_id AS vendorId,
            master.vendor_text AS vendorName,
            master.device_id AS deviceId,
            master.device_did AS deviceDid,
            master.device_text AS deviceName,
            master.class_id AS classId,
            master.class_text AS className,
            master.oem_id AS oemId,
            master.oem_did AS oemDid,
            master.oem_text AS oemName,
            master.oem_vendor_text AS oemVendor,
            master.comment AS comment,
            master.v1 AS v1,
            master.v2 AS v2,
            master.status AS status,
            dev_mod_join.mod_text AS module
FROM        master
LEFT JOIN   dev_mod_join 
       ON   master.device_did = dev_mod_join.dev_id
WHERE ( 
            master.device_text LIKE CONCAT("%", 'search term', "%")
       OR   master.vendor_text LIKE CONCAT("%", 'search term', "%")
       OR   master.oem_text LIKE CONCAT("%", 'search term', "%")
       OR   master.oem_vendor_text LIKE CONCAT("%", 'search term', "%") 
      )
GROUP BY    master.vendor_text
LIMIT     0, 25

For some reason, this is only returning one result per vendor. That is odd. There can be several devices per vendor. If I search for a vendor that I know has a lot of devices, it will still return only one device for that vendor (it also returns other devices that have other vendors, but something else matches the search term, but it only gives one per vendor).

Anything I’m missing, I think it has something to do with the “OR”s, but from what I know, that shouldn’t be the case.

Help is appreciated, as always.

EDIT: OMG, I may have just figured it out. I used GROUP BY instead of ORDER BY.

Wow, been looking at that for a while and like 5 minutes on SO and I get it

  • 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-17T08:22:14+00:00Added an answer on May 17, 2026 at 8:22 am

    The query appears to be sound for the most part, the only part that looks suspicious is the group by. Try it with a distinct in select clause instead of group by.

    Like this:

    SELECT DISTINCT      
                master.pk AS pk,
                master.vendor_id AS vendorId,
                master.vendor_text AS vendorName,
                master.device_id AS deviceId,
                master.device_did AS deviceDid,
                master.device_text AS deviceName,
                master.class_id AS classId,
                master.class_text AS className,
                master.oem_id AS oemId,
                master.oem_did AS oemDid,
                master.oem_text AS oemName,
                master.oem_vendor_text AS oemVendor,
                master.comment AS comment,
                master.v1 AS v1,
                master.v2 AS v2,
                master.status AS status,
                dev_mod_join.mod_text AS module
    FROM        master
    LEFT JOIN   dev_mod_join 
           ON   master.device_did = dev_mod_join.dev_id
    WHERE ( 
                master.device_text LIKE CONCAT("%", 'search term', "%")
           OR   master.vendor_text LIKE CONCAT("%", 'search term', "%")
           OR   master.oem_text LIKE CONCAT("%", 'search term', "%")
           OR   master.oem_vendor_text LIKE CONCAT("%", 'search term', "%") 
          )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the issue I am having: I have a large query that needs
Here is a simplification of my database: Table: Property Fields: ID, Address Table: Quote
Here's a basic regex technique that I've never managed to remember. Let's say I'm
Here's my scenario - I have an SSIS job that depends on another prior
Here's a coding problem for those that like this kind of thing. Let's see
Here is the scenario: I'm writing an app that will watch for any changes
Here's what I'm trying do to in a single SQL Server procedure: @ID1 int
Here is a link my example of the misaligned table rows Click preview in
I'm getting an error here that says I haven't defined a method, but it
This is beyond both making sense and my control. That being said here is

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.