MySQL Forums
Forum List  »  Install & Repo

Re: Rewrite of a Old MYSql Statement
Posted by: Barry Galbraith
Date: April 14, 2015 05:38PM

I rewrote your query to be more reable like this

SELECT f.pdffieldname AS name
, s.pdftaxmode AS taxmode
, s. * AS selected
, a.position AS active
, f.quotes_g_enabled AS group_enabled
, f.quotes_i_enabled AS individual_enabled
FROM crmnow_pdfcolums_sel s
INNER JOIN crmnow_pdfcolums_active a
 ON  a.pdfmodulname = s.pdfmodul 
INNER JOIN crmnow_pdf_fields f
 ON a.pdftaxmode = s.pdftaxmode
WHERE pdfmodul = 'Quotes'
AND f.pdffieldname = 'Position'

So it's a bit easier to see what's wrong with it.

Remove the * by naming the fields you want from that table. You can't alias the many fields returned with one name.

This join condition
INNER JOIN crmnow_pdf_fields f
 ON a.pdftaxmode = s.pdftaxmode
doesn't use the joined table!!! You join to crmnow_pdf_fields and then specify the ON condition to be fields in crmnow_pdfcolums_active and crmnow_pdfcolums_sel.

You need to have a clearer idea of what you are looking for.

Good luck,
Barry.

Options: ReplyQuote


Subject
Written By
Posted
Re: Rewrite of a Old MYSql Statement
April 14, 2015 05:38PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.