View Single Post

   
  #2 (permalink)  
Old 02-28-2008, 09:36 AM
Captain Paralytic
 
Posts: n/a
Default Re: Another SQL syntax problem


Matthew256 wrote:
> OK, another newbie with a dumb question. Why doesn't my query work?
>
> SELECT pmainT.product + '.75' + woodtype.short AS SKU, psubT.ID + .75
> AS id, ROUND(psubT.price * 1.65, 2) AS price,
> psubT.pmain_ID + .75 AS Expr1, psubT.woodtype_ID, psubT.weight * .75 AS
> weight, psubT.oldweight, psubT.turning
> FROM woodtype INNER JOIN
> pmainT INNER JOIN
> psubT ON pmainT.ID = psubT.pmain_ID ON woodtype.ID = psubT.woodtype_ID
> WHERE (pmainT.milling = 1) AND (pmainT.twosquares = 0)
>
> MySQL said:
> #1064 - 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 'ON woodtype . ID = psubT . woodtype_ID WHERE ( pmainT . milling
> = 1 ) AND ( pma' at line 1

Because you have your JOINs and ONs all mixed up.
Try this (tidied up a bit):

SELECT
pmainT.product + '.75' + woodtype.short AS SKU,
psubT.ID + .75 AS id,
ROUND(psubT.price * 1.65, 2) AS price,
psubT.pmain_ID + .75 AS Expr1,
psubT.woodtype_ID,
psubT.weight * .75 AS weight,
psubT.oldweight,
psubT.turning
FROM woodtype
INNER JOIN psubT ON woodtype.ID = psubT.woodtype_ID
INNER JOIN pmainT ON pmainT.ID = psubT.pmain_ID
WHERE (pmainT.milling = 1) AND (pmainT.twosquares = 0)

Reply With Quote