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

The Archive Base Latest Questions

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

I have a client database that is in a pretty poor state, but I

  • 0

I have a client database that is in a pretty poor state, but I have to work with it. We have a set of product id’s and each id is made up of the attributes of the product. What i’d like to do is select those id’s that match the first 4 or 5 characters and have them in a drop down box as variants of a selected product.

I’ve tried ‘group by subtr(0,6)’, but this seems to return only the first match in the group. What I need is to have separate queries, that ONLY return ALL the individual rows that have a matching first x characters.

So, for example, I want to have queries that will return:
12345xx
12345yy
12345zz

and then another that will return:
56789xx
56789yy
56789zz

This following query would return only:

12345xx

and then

56789yy for example

select tbl_item.Description, tbl_item.`Description 2`, tbl_item.`Inventory Posting Group`, tbl_item.No_, tbl_item.`Web Description`, tbl_item.`Web Headers`, tbl_item.`Unit Price`, tbl_item.`Sales (Qty_)`, tbl_item.`Product Group Code`
from tbl_item
where tbl_item.`Product Group Code` = ':shopprodid' and tbl_item.`Vendor No_` = '$vendor_no'
group by substr(0,6)
  • 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-24T18:28:59+00:00Added an answer on May 24, 2026 at 6:28 pm

    The solution is to put the substr and LIKE in the WHERE clause (no need to group anything). And btw, in MySql the substring starts at index 1, not 0.

    select *
    from tbl_item
    where substr(tbl_item.`Product Group Code`, 1, 6) LIKE ':shopprodid%'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database that many different client applications (a smattering of web services,
I have a client that has a PostgreSQL database and he cannot remember the
I have a client that uses a point-of-sale solution involving an Access database for
I have an internal WPF client application that accesses a database. The application is
I have a database that contains data for many clients. Currently, we insert tens
I have a client database with English and French data in windows-1252 encoding. I
I have a classic client/server (fat client and database) program written in Delphi 2006.
I have a client with a hosted MySQL database whose developer keeps asking me
I have a .net client application which is connected to a remote database. Is
Currently I have database with the following associations: One Client to Many Intakes One

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.