473,325 Members | 2,308 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Converting MSSQL to Mysql

clintw
10
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 2028
r035198x
13,262 8TB
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
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 8TB
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
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 8TB
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 8TB
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
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
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
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...
16
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
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...
0
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...
0
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...
1
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...
0
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?...
1
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.