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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:20:29+00:00 2026-05-30T06:20:29+00:00

I am working on a mysql query and its giving me headache! The Scenario:

  • 0

I am working on a mysql query and its giving me headache!

The Scenario:

I am building a website where people can select industries they are interested in (NOTIFY_INDUSTRY). I join the selected values and store in a database field.

Example: a member selects agriculture (id = 9) and oil and gas (id = 13). I join them as 9-13 and store in the database.
Users can select several industries, not limited to two.

Also, members can select an industry (COMPANY_INDUSTRY) it belongs in assuming Information Technology which is stored in the database too.

Sample table (members):

ID
EMAIL
COMPANY_NAME
COMPANY_INDUSTRY
NOTIFY_INDUSTRY

The problem:

When a new user registers on the website, mail (the mails are sent on daily basis) is sent to existing users who have the new user’s industry (COMPANY_INDUSTRY) as one of their interested industries (NOTIFY_INDUSTRY).

What i have done:

$sql="select id, email
      from members
      where notify_industry in (
        select company_industry
        from members
        where datediff($today, date_activated) <= 1)"

This does not select the right members and i do not know the right way to go about it

EDIT – Exact Problem with current output:

Does not return any row, even when it should.

Assuming the new user’s company_industry is 9, and there is an existing user with notify_industry: 10-9-20; it is meant to return the existing members email as the new member is in the existing member’s categories of interest; but i get blanks

  • 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-30T06:20:30+00:00Added an answer on May 30, 2026 at 6:20 am

    You should redesign the tables, as others have suggested.

    However, barring that, there is a gross hack you can do:

    SET sql_mode = 'ANSI';
    
        SELECT notify_members.id, notify_members.email
          FROM members notify_members
    INNER JOIN members new_members
         WHERE CURRENT_DATE - new_members.date_activated <= 1
               AND
               new_members.company_industry RLIKE ('[[:<:]](' || REPLACE(notify_members.notify_industry, '-', '|') || ')[[:>:]]');
    

    Yuck. Basically, you turn 9-13 into the MySQL regular expression [[:<:]](9|13)[[:>:]], which matches 9, 13, 13-27-61, etc., but does not match 19-131 and the like. (This supports a compound COMPANY_INDUSTRY field, too.)

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

Sidebar

Related Questions

I am working on to build a query in MYSQL by which I can
I'm working on a Mysql query to search for a single row, but its
A program I've been working on uses a complex MySQL query to combine information
I am currently working with a query in in MSSQL that looks like: SELECT
Hi Order By not working on MySql the code is as follows, select *
I was working on mysql query and could not get it running. I am
I have this mysql query using PHP and first part is working fine, but
I have a mysql query SELECT * FROM lead LIMIT 5 OFFSET 0 to
I have mysql connection and its working. Connection is done and mysql result its
I have the following MySQL query: SELECT SUM(IF(num_content>3,3,num_content)) FROM ( SELECT DATE(FROM_UNIXTIME(content_timestamp)) as dt,

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.