Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SQL statement in MySQL

Posted on 2003-12-08
6
Medium Priority
?
255 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
Technology Partners: 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 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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

722 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