Solved

MYSQL Select Statement no longer works

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
mySql Syntax 7 53
How to send multiple emails at the same time in PHP 12 58
running code or pseudo code of table structure 5 25
paypal ipn to mysql 3 36
All XML, All the Time; More Fun MySQL Tidbits – Dynamically Generate XML via Stored Procedure in MySQL Extensible Markup Language (XML) and database systems, a marriage we are seeing more and more of.  So the topics of parsing and manipulating XM…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

770 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