Solved

Syntax for MySQL text that contains a   an apostrophe

Posted on 2016-07-27
2
59 Views
Last Modified: 2016-07-30
How can I change the syntax to get this to run:

SELECT shrcode, shrfirm, shrdiv * shrqty AS [Max's Total Dividend]
     FROM shr;

It says there is an error at [ ... this runs in MS Access.

I've tried
SELECT shrcode, shrfirm, shrdiv * shrqty AS "Max's Total Dividend"
     FROM shr;

but this doesn't work either in MySQL
0
Comment
Question by:chonabraham
2 Comments
 
LVL 6

Expert Comment

by:Manuel Marienne-Duchêne
ID: 41731762
Try
SELECT shrcode, shrfirm, shrdiv ,shrqty AS 'Max''s Total Dividend'     FROM shr
OR
SELECT shrcode, shrfirm, shrdiv ,shrqty AS 'Max\'s Total Dividend'
     FROM shr
0
 
LVL 22

Accepted Solution

by:
Kim Walker earned 500 total points
ID: 41731847
Table names, column names, and aliases are considered identifiers. The identifier quote character is the backtick (“`”). So try:
SELECT shrcode, shrfirm, shrdiv * shrqty AS `Max's Total Dividend`
     FROM shr;

Open in new window

0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

I use MySQL for many of my development projects in a Windows environment. To manage my databases (and perform queries) for years I used a tool called MySQL administrator.  This tool has since been replaced by MySQL Workbench. So I decided to m…
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://…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

792 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