Note that there are some explanatory texts on larger screens.

plurals
  1. POConditional Select in MySQL
    text
    copied!<p>I am working on a mysql query and its giving me headache!</p> <p><strong>The Scenario:</strong></p> <p>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.</p> <p>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.</p> <p>Also, members can select an industry (COMPANY_INDUSTRY) it belongs in assuming Information Technology which is stored in the database too.</p> <pre><code>Sample table (members): ID EMAIL COMPANY_NAME COMPANY_INDUSTRY NOTIFY_INDUSTRY </code></pre> <p><strong>The problem:</strong></p> <p>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).</p> <p><strong>What i have done:</strong></p> <pre><code>$sql="select id, email from members where notify_industry in ( select company_industry from members where datediff($today, date_activated) &lt;= 1)" </code></pre> <p>This does not select the right members and i do not know the right way to go about it</p> <p><strong>EDIT - Exact Problem with current output:</strong></p> <p>Does not return any row, even when it should.</p> <p>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</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload