Solved

MYSQL Select Statement no longer works

Posted on 2013-05-16
3
464 Views
Last Modified: 2013-05-16
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
0
Comment
Question by:gracetec
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 20

Accepted Solution

by:
dsacker earned 400 total points
ID: 39171191
Take off the single quotes. Or if all you want is all columns from all tables, simply SELECT * FROM ....
0
 

Author Closing Comment

by:gracetec
ID: 39171414
Thanks for your help, I couldn't figure it out :)
0
 
LVL 22

Expert Comment

by:Kim Walker
ID: 39171473
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.
0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This guide whil teach how to setup live replication (database mirroring) on 2 servers for backup or other purposes. In our example situation we have this network schema (see atachment). We need to replicate EVERY executed SQL query on server 1 to…
Foreword This is an old article.  Instead of using the MySQL extension that was used in the original code examples, please choose one of the currently supported database extensions instead.  More information is available here: MySQLi / PDO (http://…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question