Solved

SQL statement in MySQL

Posted on 2003-12-08
6
254 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
Get Database Help Now w/ Support & Database Audit

Keeping your database environment tuned, optimized and high-performance is key to achieving business goals. If your database goes down, so does your business. Percona experts have a long history of helping enterprises ensure their databases are running smoothly.

 
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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…
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.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

632 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