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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:48:48+00:00 2026-05-23T01:48:48+00:00

I have a table of spec numbers that require additional comments to be entered

  • 0

I have a table of spec numbers that require additional comments to be entered on a printed form when the form is generated. When I am generating that form, I have a list of products and their associated spec numbers. Some of the “normal” products are just plain old eight-digit numbers and I can easily search my comment table for a matching spec number and pull the appropriate comment. But there are also “special” products that have a suffix appended (for instance, 52498762 vs. 52498762-A4). Depending on the suffix used (there are two or three), any product with that suffix needs the comment listed. But when the comment table was set up, rather than specify each individual spec number with that suffix, the spec field has just the suffix. For example:

SpecID    |  Comment
------------------------------------------------------
52498762  |  Comment for a specific spec number
52746627  |  Comment for a different spec number
A4        |  Comment for any spec that ends with '-A4'

So in this example, if I had a spec number of 52196748-A4, it would need the comment listed in the ‘A4’ row of the comment table. I could have two hundred specs ending in -A4, and they would all get the same comment. Is there a way of writing a query that matches a wildcard version of the table contents? I know normally one matches a fixed value in a table against a wildcard user-supplied value; what I need is a static user-supplied value and a wildcard table value. Is that even possible?

  • 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-23T01:48:48+00:00Added an answer on May 23, 2026 at 1:48 am

    Why not get both sets of comments at once?

    SELECT
       ...
    FROM
       Products P
       LEFT JOIN Comments C
          ON P.ProductID LIKE C.SpecID + '%'
          OR P.ProductID LIKE '%-' + C.SpecID
    

    Also you could consider:

    SELECT
       ...
    FROM
       Products P
       LEFT JOIN Comments C
          ON (Len(C.SpecID) = 2 AND P.ProductID LIKE C.SpecID + '%')
          OR (Len(C.SpecID) > 2 AND P.ProductID LIKE '%-' + C.SpecID)
    

    Testing is in order to see if one performs better than the other. If you find the queries to be too slow, then trying adding some persisted calculated columns: in Products to specify whether the product ID has a dash in it or not, and in Comments add two columns, one with only product IDs and one with only suffices. Indexes on these columns could help.

    ALTER TABLE Comments ADD ExactSpecID AS 
       (CASE WHEN Len(SpecID) > 2 THEN SpecID ELSE NULL END) PERSISTED
    ALTER TABLE Comments ADD Suffix AS 
       (CASE WHEN Len(SpecID) = 2 THEN SpecID ELSE NULL END) PERSISTED
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table in a SQL Server 2005 database with a trigger that
I have a table which is full of arbitrarily formatted phone numbers, like this
I have table that has a column of type DateTime, I would like to
I have a script that appends some rows to a table. One of the
I have a table that I added a column called phone - the table
I have a php file that receives data from mySQL table. The mySQL table
I have a table with a date column that I know is stored in
I have table view which is showing list of files to download. When I
I have table with articles and there is around 150.000 of records, in that
Hello I have table name FriendsData that contains duplicate records as shown below fID

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.