gracetec
asked on
MYSQL Select Statement no longer works
Hi
I have recently move a web application onto MySQL 5 and the following select statement no longer works.
When I run the query in PHPMyAdmin, it returns 3 rows in the following format.
tact.* tcp.* te.* [table header]
tact.* tcp.* te.*
tact.* tcp.* te.*
tact.* tcp.* te.*
I would be grateful for somehelp as I'm not an expert on SQL statements
I have recently move a web application onto MySQL 5 and the following select statement no longer works.
When I run the query in PHPMyAdmin, it returns 3 rows in the following format.
tact.* tcp.* te.* [table header]
tact.* tcp.* te.*
tact.* tcp.* te.*
tact.* tcp.* te.*
SELECT 'tact.*', 'tcp.*', 'te.*' FROM tblaction AS tact, tblcomproblem AS tcp, tblcalllog AS tclog, tblengineers AS te WHERE tcp.prId = tclog.clProblemReported AND tclog.clId=tact.clId AND tact.clId = 41305160002 AND tact.eId = te.eId ORDER BY aDate ASC LIMIT 0, 15
I would be grateful for somehelp as I'm not an expert on SQL statements
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
dsacker is correct. The single quotes are wrong. They should be removed or you should use tick marks (under the tilde beside the 1 key on your keyboard) around your table and field names. For example
SELECT
`tact`.*,
`tcp`.*,
`te`.*
FROM
`tblaction` AS `tact`,
`tblcomproblem` AS `tcp`,
`tblcalllog` AS `tclog`,
`tblengineers` AS `te`
WHERE
`tcp`.`prId` = `tclog`.`clProblemReported`
AND `tclog`.`clId` = `tact`.`clId`
AND `tact`.`clId` = 41305160002
AND `tact`.`eId` = `te`.`eId`
ORDER BY
`aDate` ASC
LIMIT
0, 15
Tick marks are primarily used to avoid table name and field name conflicts with reserved words. In your case they are unnecessary but I use them religiously to avoid any possibility of conflict.
ASKER