Hi i have two sql statements the first one is
$sql = "SELECT TOP 2
ReaderData.ReaderIndex,
ReaderData.CardID,
ReaderData.ReaderDate,
ReaderData.ReaderTime,
ReaderData.controllerID,
Left([dtReading],10) AS [date],
ReaderData.dtReading
FROM ReaderData
WHERE ReaderData.controllerID=$this->Id
ORDER BY ReaderData.ReaderIndex desc;";
and the second one which is
$sql = "SELECT
[SHOP FLOOR PRODUCTION PLAN].[MACHINE],
[SHOP FLOOR PRODUCTION PLAN].[cycletime]
WHERE [SHOP FLOOR PRODUCTION PLAN].[MACHINE]=$this->name
FROM [SHOP FLOOR PRODUCTION PLAN]";
the first one works as expected however the second one does not work with the WHERE in there if i remove it then it spits out one of the enterys in the table and i am not sure why Any help would be appreciated
Since I am assuming [SHOP FLOOR PRODUCTION PLAN].[MACHINE]
is a string, try putting quotes around the dynamic $this->name
part of the query. e.g.
WHERE [SHOP FLOOR PRODUCTION PLAN].[MACHINE]='$this->name'
Also, the WHERE
clause must appear after the FROM
clause:
SELECT [SHOP FLOOR PRODUCTION PLAN].[MACHINE], [SHOP FLOOR PRODUCTION PLAN].[cycletime] FROM [SHOP FLOOR PRODUCTION PLAN] WHERE [SHOP FLOOR PRODUCTION PLAN].[MACHINE]='$this->name'