close ad
Help us test the new Databridge BETA with MySQLi support
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

SQL query not working; but works using Navicat

Thread began 5/07/2018 8:28 am by msbannister373603 | Last modified 5/08/2018 4:32 pm by msbannister373603 | 65 views | 10 replies

Ray BorduinWebAssist

The issue is that you are doing a complex calculation and not giving it a name, so it is trying to return the column name as the calculation and that has the '-' character that is a math operator and that throws the whole thing off.

The solution is to use AS to assign a name to your calculated result like:

$pab->setQuery("SELECT
((SELECT COUNT(pa) as pabpct FROM bat WHERE (teamID = ? ) AND
(
(result = 'BB') OR
(result = 'HBP') OR
(result = '1B') OR
(move_run = '1') OR
(xbh = '1') OR
(OB = '1') OR
(result = 'Bunt') OR
(result = '2B') OR
(result = '3B') OR
(result = 'HR') OR
(result = 'SC-Fly') OR
(result = 'D3-Safe') OR
(result = 'SC-BNT') OR
(rbi > '0') OR
(result = 'ROE-No Out')
)) / (SELECT COUNT(pa) FROM bat)) AS totpabpct");

That way it returns your calculated number as a column named: totpabpct

before it was trying to create a column named: "((SELECT COUNT(pa) as pabpct FROM bat WHERE (teamID = ? ) AND
(
(result = 'BB') OR
(result = 'HBP') OR
(result = '1B') OR
(move_run = '1') OR
(xbh = '1') OR
(OB = '1') OR
(result = 'Bunt') OR
(result = '2B') OR
(result = '3B') OR
(result = 'HR') OR
(result = 'SC-Fly') OR
(result = 'D3-Safe') OR
(result = 'SC-BNT') OR
(rbi > '0') OR
(result = 'ROE-No Out')
)) / (SELECT COUNT(pa) FROM bat))"

Which almost was allowed if not for the "-" characters in it.

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...