greenlion / PHP-SQL-Parser

A pure PHP SQL (non validating) parser w/ focus on MySQL dialect of SQL
BSD 3-Clause "New" or "Revised" License
604 stars 156 forks source link

CREATE TABLE mytable SELECT ... throws exception in PositionCalulator Line 199 #382

Open BriegerCA opened 7 months ago

BriegerCA commented 7 months ago

SQL Statement works fine with PHPMyadmin or mysqli->query

create table mytable SELECT timeheader.Project, CONCAT('$',timeheader.Expenses) As Expenses, DATE_FORMAT(timedetail.RowDate,'%d/%m/%Y') AS Datum,SEC_TO_TIME(SUM( TIME_TO_SEC( timedetail.Duration ))) AS Hours, CONCAT('$',FORMAT(timeheader.Intern_Rate,2,'en_US')) as 'Intern per Hour', CONCAT('$',FORMAT(SUM( TIME_TO_SEC( timedetail.Duration ))/3600timeheader.Intern_Rate,2,'en_US')) AS 'Internal Cost', CONCAT('$',FORMAT(timeheader.Extern_Rate,2,'en_US')) as 'Extern per Hour', CONCAT('$',FORMAT(SUM( TIME_TO_SEC( timedetail.Duration ))/3600timeheader.Extern_Rate,2,'en_US')) AS 'Extern Cost', CONCAT('$',FORMAT(125,2,'en_US')) as 'Billable per Hour', CONCAT('$',FORMAT((SUM( TIME_TO_SEC( timedetail.Duration ))*(125/3600))+timeheader.Expenses,2,'en_US')) AS 'Billable' FROM timedetail LEFT JOIN timeheader ON timedetail.Identifyer = timeheader.Identifyer group by timeheader.Identifyer, timeheader.Project, timeheader.Intern_Rate, timeheader.Extern_Rate, timeheader.Expenses, timedetail.RowDate order by timeheader.Identifyer, timedetail.RowDate;