Link to home
Create AccountLog in
Avatar of gracetec
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.*

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

Open in new window


I would be grateful for somehelp as I'm not an expert on SQL statements
ASKER CERTIFIED SOLUTION
Avatar of dsacker
dsacker
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of gracetec
gracetec

ASKER

Thanks for your help, I couldn't figure it out :)
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

Open in new window

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.