Solved

SQL statement in MySQL

Posted on 2003-12-08
6
249 Views
Last Modified: 2013-11-20
Hi there,

Anyone can guess what's wrong with this SQL statement in MySQL?

SQL = "SELECT TopicPKey,TopicNo,Description, [TopicNo] & ' - ' & [Description] AS TopicDescription FROM viewTopics WHERE fSubjectPKey=" & SubjectPKey & " ORDER BY TopicNo"

The same statement works for MSAccess but not MySQL, the TopicDescription returns as 0 in MySQL, where as something like "1.0 - Grammer" in MSAccess, which is correct.

0
Comment
Question by:kwseow
  • 3
  • 2
6 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 9896232
Does the & char give problems in MySQL?  Maybe put Description in [] in the SELECT clause.
The SQL command you give returns both TopicNo and Description AND a field constructed from both (TopicDescription).  Why not do the construction when you require it rather than in the SQL.  (Less data retrieved from server)
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 9896239
It looks like the MySQL is attempting to subtract Description from TopicNo
0
 

Author Comment

by:kwseow
ID: 9896557
I'm sorry, the sql statement list above give a error. NOT returning 0.

AndyAinscow, Why I'm doing this is because I wants to bind the data to a DataCombo to display TopicNo - Description.


0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 44

Expert Comment

by:AndyAinscow
ID: 9896884
Does the & char give problems in MySQL?  (could it require a + chat instead?)
0
 
LVL 6

Accepted Solution

by:
Triskelion earned 125 total points
ID: 9899024
If you're doing this in a script or with raw mySQL code, you should replace the 'concat()' keyword.
SELECT TopicPKey,TopicNo,Description, concat(TopicNo, ' - ' ,Description) AS TopicDescription
FROM ...
0
 

Author Comment

by:kwseow
ID: 9900901
Thanks Trikelion, and all who contributed !

0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

746 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