MySQL Forums
Forum List  »  Newbie

Re: MSSQL to MySQL
Posted by: Bill Karwin
Date: April 05, 2006 11:05AM

MySQL 4.1 and later versions support subqueries.
You can get your MySQL version with: "SHOW VARIABLES LIKE 'version';"
If it's 4.0 or less, you can't use subqueries.

However, you should be able to rewrite this query without subqueries, and it may even run faster this way:

SELECT o.*,
i.ItmName, i.CategoryID, i.ClientID,
c.CatName AS CategoryName,
CONCAT(cl.FName, ' ', cl.LName) AS ClientName,
it.ItmName AS ItemTYpeName,
it.RecordID AS ItemTypeID
FROM Offers AS o
INNER JOIN Items AS i ON i.RecordID = o.ItemID
INNER JOIN Categories AS c ON c.RecordID = i.CategoryID
INNER JOIN Clients AS cl ON cl.RecordID = i.ClientID
INNER JOIN ItemTypes AS it ON it.RecordID = i.ItmType
ORDER BY o.DteAdded DESC

Note also the use of CONCAT() instead of the Microsoft-proprietary '+' syntax for string concatentation.

Regards,
Bill K.

Options: ReplyQuote


Subject
Written By
Posted
April 05, 2006 06:33AM
April 05, 2006 07:02AM
April 05, 2006 08:27AM
Re: MSSQL to MySQL
April 05, 2006 11:05AM
April 05, 2006 02:28PM
April 05, 2006 11:26PM
April 06, 2006 12:18PM
April 06, 2006 03:51PM


Sorry, you can't reply to this topic. It has been closed.
This forum is currently read only. You can not log in or make any changes. This is a temporary situation.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.