Solved

MYSQL Select Statement no longer works

Posted on 2013-05-16
3
454 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
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 21

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now