Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SQL statement in MySQL

Posted on 2003-12-08
6
Medium Priority
?
256 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 45

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 45

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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 45

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 375 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

782 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