|
-
Jul 26th, 2011, 10:48 AM
#1
Thread Starter
Lively Member
[RESOLVED] MySQL syntax error
hi.. i am trying to do a INSERT, SELECT and inner join statement together and i received this error..
My SQL syntax
Code:
INSERT INTO TableSalesReportMU (AirWayBillNumber, FlightDate, DepartureFrom, Destination, Via1, GrossWt, ChargeableWt, Prepaid, TotalPrepaid, FreightCollect, Comm, DueAgent, Fuel, Security, Others, DueCarrier, FreightDue, Discount, CarrierRate, Airline, IATARate, DGR ) SELECT TableAWBDetails.AirWayBillNumber, TableAWBDetails.FlightDate, TableAWBDetails.DepartureFrom,TableAWBDetails.Destination, TableAWBDetails.Via1, TableAWBDetails.GrossWeight, TableAWBDetails.CostingChargeableWeight,
TableAWBDetails.Prepaid, TableAWBDetails.TotalPrepaid, TableAWBDetails.FreightCollect, TableAWBDetails.Comm,
TableAWBDetails.DueAgent, TableAWBDetails.Fuel, TableAWBDetails.Security, TableAWBDetails.Others,
TableAWBDetails.DueCarrier, TableAWBDetails.FreightDue, TableAWBDetails.Discount, TableAWBDetails.CarrierRate
TableAWB.Airline, TableAWBDetails.IATARate, TableAWBDetails.DGR FROM (TableAWB INNER JOIN TableAWBDetails ON TableAWB.AirWayBillNumber = TableAWBDetails.AirWayBillNumber)
WHERE TableAWB.Airline='MU' and TableAWBDetails.Report = 'MU' AND (TableAWB.Costing <> 0 or TableAWBDetails.Destination = 'CNX')
AND TableAWBDetails.FirstHalf = True AND Month = 'June' AND Year = '2011'
error:
Code:
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 '.Airline, TableAWBDetails.IATARate, TableAWBDetails.DGR FROM (TableAWB INNER JOI' at line 5
Table Datatype:
TableAWB:

TableAWBDetails:

TableAWBDetails Cont:

TableSalesReportMU

Uploaded with ImageShack.us
i am using MySQL server 5.5
Last edited by bczm8703; Jul 26th, 2011 at 11:18 AM.
-
Jul 26th, 2011, 11:29 AM
#2
Re: MySQL syntax error
When you get an error with a long SQL statement, the best thing to do is format it so that you can read it properly (rather than being a few massively long lines).
Once you do that, the problem (and thus solution) should be reasonably easy to find - it is soon before the text that the error message showed you.
-
Jul 26th, 2011, 11:30 AM
#3
Re: MySQL syntax error
A simple sytax check failes in MS SQL and I guess it is the same for MYSQL. A comma is missing here:
TableAWBDetails.CarrierRate TableAWB.Airline,
-
Jul 26th, 2011, 12:51 PM
#4
Re: MySQL syntax error
A free tool to format sql is available here.
Using this tool, I was able to format your sql to a more readable format.
Code:
INSERT INTO tablesalesreportmu
(airwaybillnumber,
flightdate,
departurefrom,
destination,
via1,
grosswt,
chargeablewt,
prepaid,
totalprepaid,
freightcollect,
comm,
dueagent,
fuel,
SECURITY,
others,
duecarrier,
freightdue,
discount,
carrierrate,
airline,
iatarate,
dgr)
SELECT tableawbdetails.airwaybillnumber,
tableawbdetails.flightdate,
tableawbdetails.departurefrom,
tableawbdetails.destination,
tableawbdetails.via1,
tableawbdetails.grossweight,
tableawbdetails.costingchargeableweight,
tableawbdetails.prepaid,
tableawbdetails.totalprepaid,
tableawbdetails.freightcollect,
tableawbdetails.comm,
tableawbdetails.dueagent,
tableawbdetails.fuel,
tableawbdetails.SECURITY,
tableawbdetails.others,
tableawbdetails.duecarrier,
tableawbdetails.freightdue,
tableawbdetails.discount,
tableawbdetails.carrierrate tableawb.airline,
tableawbdetails.iatarate,
tableawbdetails.dgr
FROM (tableawb
INNER JOIN tableawbdetails
ON tableawb.airwaybillnumber = tableawbdetails.airwaybillnumber)
WHERE tableawb.airline = 'MU'
AND tableawbdetails.report = 'MU'
AND ( tableawb.costing <> 0
OR tableawbdetails.destination = 'CNX' )
AND tableawbdetails.firsthalf = true
AND MONTH = 'June'
AND YEAR = '2011'
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
-
Jul 26th, 2011, 11:53 PM
#5
Thread Starter
Lively Member
Re: MySQL syntax error
thx for the help... i solve the error
-
Jul 27th, 2011, 05:24 AM
#6
Re: MySQL syntax error
"Using this tool, I was able to format your sql to a more readable format"
Cool tool
-
Jul 27th, 2011, 01:18 PM
#7
Re: MySQL syntax error
 Originally Posted by TysonLPrice
"Using this tool, I was able to format your sql to a more readable format"
Cool tool 
yes, everyone should book mark it.
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|