I am getting an error in my statement and I cannot figure out why.
Here is my select statement:
Here is my error:PHP Code:$today = date('Y-m-d');
$arrCompanies = func_query(SELECT companies.company_name, company_dates.day FROM companies, company_dates WHERE companies.companyid IN (SELECT DISTINCT companyid FROM company_dates WHERE date >= $today));
Now if I query the IN part seperatlyPHP Code:INVALID SQL: 1064 : You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT DISTINCT companyid FROM company_dates WHERE date >
SQL QUERY FAILURE: SELECT DISTINCT company_name, xcart_company_dates.day FROM xcart_companies, xcart_company_dates WHERE xcart_companies.companyid IN (SELECT DISTINCT companyid FROM company_dates WHERE date >= 2005-06-12)
It returns:PHP Code:$arrTemp = func_query(SELECT DISTINCT companyid FROM company_dates WHERE date >= $today));
I am assuming I am writing the IN part wrong. What I want to happen is for the first query to select those fields WHERE the companyid of that row is IN the array or select statement in the ()'s.PHP Code:Array ( [0] => Array ( [companyid] => 1 ) [1] => Array ( [companyid] => 9 ) )
So if I hard coded it would look like:
Any ideas on how to get this result?PHP Code:$today = date('Y-m-d');
$arrCompanies = func_query(SELECT companies.company_name, company_dates.day FROM companies, company_dates WHERE companies.companyid IN (1,9));
If I type out the select statment is would be something like:
SELECT company_name and date value FROM companies, company_date tables WHERE companyid value is in the result of (Select distinct companyid FROM company_dates WHERE date field is greater than or equal to today's date)








Bookmarks