Converting Access query to MySQL

Hi,
I've done a lot of searching and can't seem to find exactly what I need.
I have a query in Access that I need to convert to MySQL syntax.

My Access query is:

SELECT org_param_value.param_id, org_param_value.param_value, org_param_value.param_effective_date, org_param_value.param_rag, daily_report_items.cmi_id, daily_report_items.cmi_title, daily_report_name.cmn_id, daily_report_name.cmn_title

FROM (daily_report_items INNER JOIN daily_report_name ON daily_report_items.cmn_id = daily_report_name.cmn_id) INNER JOIN org_param_value ON daily_report_items.cmi_param = org_param_value.param_id

WHERE (((org_param_value.param_status)=1) AND ((daily_report_name.cmn_id)=850 Or (daily_report_name.cmn_id)=1388 Or (daily_report_name.cmn_id)=1389 Or (daily_report_name.cmn_id)=1346) AND ((org_param_value.param_date)>=#10/1/2015# And (org_param_value.param_date)<#10/20/2015#))

GROUP BY org_param_value.param_id, org_param_value.param_value, org_param_value.param_effective_date, org_param_value.param_rag, daily_report_items.cmi_id, daily_report_items.cmi_title, daily_report_name.cmn_id, daily_report_name.cmn_title;

Open in new window


Thanks in advance
Kerry LawlerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Only thing that looks out of place to me is the use of the # as date delimiters. Try using the single quote instead ( ' ).
Dale FyeOwner, Developing Solutions LLCCommented:
I don't generally use MySQL, but I would think that the extra set of () in your join clause is probably causing problems as well.  I know SQL Server does not use those.  You might also want to consider use of the IN( ) clause instead of the ORs

SELECT org_param_value.param_id
, org_param_value.param_value
, org_param_value.param_effective_date
, org_param_value.param_rag
, daily_report_items.cmi_id
, daily_report_items.cmi_title
, daily_report_name.cmn_id
, daily_report_name.cmn_title
FROM daily_report_items 
INNER JOIN daily_report_name ON daily_report_items.cmn_id = daily_report_name.cmn_id
INNER JOIN org_param_value ON daily_report_items.cmi_param = org_param_value.param_id

WHERE ((org_param_value.param_status=1) 
AND (daily_report_name.cmn_id IN (850, 1388, 1389, 1346))
AND (org_param_value.param_date >= '10/1/2015') 
AND (org_param_value.param_date < '10/20/2015'))

GROUP BY org_param_value.param_id, org_param_value.param_value
, org_param_value.param_effective_date, org_param_value.param_rag
, daily_report_items.cmi_id, daily_report_items.cmi_title
, daily_report_name.cmn_id, daily_report_name.cmn_title;

Open in new window

You might also want to consider changing the date formatting to yyyy/mm/dd format, since that is more universally understood.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PortletPaulEE Topic AdvisorCommented:
Not sure that date iterals in this sequence will work: MM / DD / YYYY

I suggest you try YYYY-MM-DD instead

You can also get rid of ALL the parentheses in the FROM clause, only Access likes those, hey are ignored by most RDBMS platforms.

The WHERE clause can also be simplified by using IN (...) and most parentheses become redundant in that clause also.
SELECT
      org_param_value.param_id
    , org_param_value.param_value
    , org_param_value.param_effective_date
    , org_param_value.param_rag
    , daily_report_items.cmi_id
    , daily_report_items.cmi_title
    , daily_report_name.cmn_id
    , daily_report_name.cmn_title
FROM daily_report_items
      INNER JOIN daily_report_name ON daily_report_items.cmn_id = daily_report_name.cmn_id
      INNER JOIN org_param_value ON daily_report_items.cmi_param = org_param_value.param_id
WHERE org_param_value.param_status = 1
      AND daily_report_name.cmn_id IN (850,1388,1389,1346)
      AND org_param_value.param_date >= '2015-10-01'
      AND org_param_value.param_date < '2015-10-20'
GROUP BY
      org_param_value.param_id
    , org_param_value.param_value
    , org_param_value.param_effective_date
    , org_param_value.param_rag
    , daily_report_items.cmi_id
    , daily_report_items.cmi_title
    , daily_report_name.cmn_id
    , daily_report_name.cmn_title;

Open in new window

Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

PortletPaulEE Topic AdvisorCommented:
snap?
PortletPaulEE Topic AdvisorCommented:
By the way you could use "SELECT DISTINCT" instead of using GROUP BY in that query.
Athar SyedCommented:
My 2 cents

SELECT org_param_value.param_id
	, org_param_value.param_value
	, org_param_value.param_effective_date
	, org_param_value.param_rag
	, daily_report_items.cmi_id
	, daily_report_items.cmi_title
	, daily_report_name.cmn_id
	, daily_report_name.cmn_title
FROM daily_report_items
	INNER JOIN daily_report_name 
		ON daily_report_items.cmn_id = daily_report_name.cmn_id
	INNER JOIN org_param_value 
		ON daily_report_items.cmi_param = org_param_value.param_id
WHERE (org_param_value.param_status=1) 
	AND (daily_report_name.cmn_id IN (850,1388,1389,1346))
	AND (org_param_value.param_date>='2015-10-01 00:00:00')
	AND (org_param_value.param_date<'2015-10-20 00:00:00')
GROUP BY org_param_value.param_id
	, org_param_value.param_value
	, org_param_value.param_effective_date
	, org_param_value.param_rag
	, daily_report_items.cmi_id
	, daily_report_items.cmi_title
	, daily_report_name.cmn_id
	, daily_report_name.cmn_title;

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.