473,769 Members | 7,355 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Converting MSSQL to Mysql

clintw
10 New Member
I'm trying to convert a MSSQL select statement to MySQL, but am having difficulty with the following section:

Expand|Select|Wrap|Line Numbers
  1. ...
  2. INNER JOIN tableA ON tableB.field1 = tableA.field1
  3. INNER JOIN tableC ON tableA.field2 = tableC.field2 
  4. ON tableD.field4 = tableB.field4
  5. ON tableE.field5 = tableC.field5 
  6. ON tableF.field6 = tableB.field6
  7. ORDER BY tableD.field7 DESC
  8. LIMIT 0,100
  9.  
Result:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ON tableF.field6 = tableB.field6 ORDER BY'

The MSSQL code works perfectly in MSSQL, but MySQL doesn't like the syntax of the last section. Is there anyone who would be willing to assist?

I'm using Mysql 5.0.38.

Thanks in advance
Sep 17 '07 #1
7 2063
r035198x
13,262 MVP
I'm trying to convert a MSSQL select statement to MySQL, but am having difficulty with the following section:

Expand|Select|Wrap|Line Numbers
  1. ...
  2. INNER JOIN tableA ON tableB.field1 = tableA.field1
  3. INNER JOIN tableC ON tableA.field2 = tableC.field2 
  4. ON tableD.field4 = tableB.field4
  5. ON tableE.field5 = tableC.field5 
  6. ON tableF.field6 = tableB.field6
  7. ORDER BY tableD.field.7 DESC
  8. LIMIT 0,100
  9.  
Result:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ON tableF.field6 = tableB.field6 ORDER BY'

The MSSQL code works perfectly in MSSQL, but MySQL doesn't like the syntax of the last section. Is there anyone who would be willing to assist?

I'm using Mysql 5.0.38.

Thanks in advance
Do you have it as ORDER BY tableD.field.7 or ORDER BY tableD.field7 ?
Sep 17 '07 #2
clintw
10 New Member
Do you have it as ORDER BY tableD.field.7 or ORDER BY tableD.field7 ?

That was a typo - sorry. It should read "ORDER BY tableD.field7 DESC". I've rectified it in my original post.
Sep 17 '07 #3
r035198x
13,262 MVP
I'm trying to convert a MSSQL select statement to MySQL, but am having difficulty with the following section:

Expand|Select|Wrap|Line Numbers
  1. ...
  2. INNER JOIN tableA ON tableB.field1 = tableA.field1
  3. INNER JOIN tableC ON tableA.field2 = tableC.field2 
  4. ON tableD.field4 = tableB.field4
  5. ON tableE.field5 = tableC.field5 
  6. ON tableF.field6 = tableB.field6
  7. ORDER BY tableD.field7 DESC
  8. LIMIT 0,100
  9.  
Result:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ON tableF.field6 = tableB.field6 ORDER BY'

The MSSQL code works perfectly in MSSQL, but MySQL doesn't like the syntax of the last section. Is there anyone who would be willing to assist?

I'm using Mysql 5.0.38.

Thanks in advance
Try it as


Expand|Select|Wrap|Line Numbers
  1.  INNER JOIN tableA ON tableB.field1 = tableA.field1
  2. INNER JOIN tableC ON tableA.field2 = tableC.field2 
  3. ON (tableD.field4 = tableB.field4
  4.   and tableE.field5 = tableC.field5 
  5.   and tableF.field6 = tableB.field6)
  6. ORDER BY tableD.field7 DESC
  7. LIMIT 0,100
and post any error messages you get
Sep 17 '07 #4
clintw
10 New Member
I've added the brackets and replaced the ON with AND, but the error remains much the same:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY tableD.field7 DESC
LIMIT 0,' at line 36

I think I've tried this already, based on what I read on mysql.com and the correct syntax for JOINS.
Sep 17 '07 #5
r035198x
13,262 MVP
I've added the brackets and replaced the ON with AND, but the error remains much the same:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY tableD.field7 DESC
LIMIT 0,' at line 36

I think I've tried this already, based on what I read on mysql.com and the correct syntax for JOINS.
There is still another ON that needs to be replaced by AND in the code that I gave you.
Sep 17 '07 #6
r035198x
13,262 MVP
There is still another ON that needs to be replaced by AND in the code that I gave you.
Just looking on you query again. Which table are you selecting from?
Shouldn't you have it as

Expand|Select|Wrap|Line Numbers
  1. from tableName innner join tableA on (tableName.field = tableA.field and tableName.anotherField = tableA.anotherField and e.t.c)
  2. innner join tableB on (tableName.field = tableB.field)
  3. inner joing tableC on (tableName.field = tableC.field)
  4. e.t.c 
  5.  
Sep 17 '07 #7
clintw
10 New Member
Selection is made FROM tableF. Will try rewriting this statement from scratch, the MSSQL was done by someone else.

Just looking on you query again. Which table are you selecting from?
Shouldn't you have it as

Expand|Select|Wrap|Line Numbers
  1. from tableName innner join tableA on (tableName.field = tableA.field and tableName.anotherField = tableA.anotherField and e.t.c)
  2. innner join tableB on (tableName.field = tableB.field)
  3. inner joing tableC on (tableName.field = tableC.field)
  4. e.t.c 
  5.  
Sep 17 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

5
12026
by: Alper Adatoz | last post by:
Hi, i have a little problem. i hope u guys give me a clear solution (: db: mssql i just want to put jpeg file to the image field at the mssql db. and after that i want to call it back..
1
3407
by: Gordan | last post by:
Hi, I have a site written in PHP with MS SQL Server 2000 as the db backend. When the site was made there was no need for advanced banner rotation so a 10 line script was written and it served well for years but now there's a need for a much more powerful banner rotation. At first I thought to buy some banner management app but after some time I realized that phpMyAdmin is the best thing. The problem is PMA uses MySQL. I can install...
16
1765
by: davemateer | last post by:
Hi We have a current system: Linux / Apache / PHP4.x talking to Microsoft SQL 2000 Thinking about going to: Windows 2003 / PHP4.x talking to the same Microsoft SQL 2000 box...
0
7948
by: m3rajk | last post by:
I've recently become the defacto DBA of two MSSQL databases at work because I am the only one with SQL experience. I have been asked to do some tasks with the databases but this requires and understanding of their structure. I cannot find anything akin to MySQL's mysqldump for mssql and have been looking for that among other help in being able to use my MySQL experience as a base for learning MSSQL. I have spent a few days (8 to 9 hours per day)...
0
1522
by: exclaim | last post by:
Apologies if this is not the right forum. I have an application written originally to work with MySQL which now has to be extended to work with MSSQL also. I have modified all my database calls to use the PEAR MDB2 methods rather than mysqli. Everything still works fine with MySQL, but I have an odd problem when I test against MSSQL. Any database query which does not return a resultset is OK e.g. an update works fine. If I execute a...
0
1776
by: Gosth in the shell | last post by:
Hi there, i need some help I got a software to backend is MSSQL 2005, but a provider software requires an UPDATE on his table with MySQL 5.0.56a backend, so i made the next: download and install ODBC MySQL 3.51 configuring system DSN add a linked server on MSSQL 2005
1
2137
by: rajanji | last post by:
Hi All, Hw r u ???? Hope u all r doing gr8... Actually i have designed a website on jobportal in asp.net using sqlserver 2005 as a backend... and now m trying to convert its database to mysql.... I have installed and configured mysql correctly and all the libraries and namespaces working fine for mysql in my existing application... and also using the quick replace facility i have changed the namespaces i.e from System.data.sqlclient to...
0
1568
by: johnyjj2 | last post by:
Hello! I've got web application written in MSSQL and I need to run it on server. But on the server I've go MySQL (not MSSQL), PHP, KFWS. Do I have to install MSSQL and have both MySQL and MSSQL? Won't it make any problems? Can I use 4CRM SQL 5.1.4 or EMS MS SQL Manager Lite 1.8 to run my MSSQL web application? How to run it? (In the web application I've got two directories. One which I copied to htdocs on KFWS, the other with scripts. At the...
1
9586
ssnaik84
by: ssnaik84 | last post by:
Hi Guys, Last year I got a chance to work with R&D team, which was working on DB scripts conversion.. Though there is migration tool available, it converts only tables and constraints.. Rest of things (stored procedures, functions).. we have to manually edit. That time, we face some interesting challenges.. I failed to document all of them, but whatever I can share with u.. I will try.. :) ...
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10216
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5309
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.