Solved

SQL statement in MySQL

Posted on 2003-12-08
6
253 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
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 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
bobThere java chalenge 45 97
Installing Microsoft R server on REDHAT or SUSE Linux 4 162
how to monitor remote shell execution on linux 9 113
MaxSpan challenge 9 140
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…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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 recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

739 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