Recently we changed from MySQL to MSSQL everything went fine except:
- The LIMIT function is not supported in MSSQL, i searched alot of forums to find out what trick is used to get it working with MSSQL, the solution was found with the TOP function, I have a query working:
SELECT *
FROM (SELECT TOP 5 menu_naam, menu_link, menu_id
FROM (SELECT TOP 20 menu_naam, menu_link, menu_id
FROM menu
ORDER BY menu_id) AS tbl1
ORDER BY menu_id DESC) tbl2
ORDER BY menu_id
But the problem is how am I going to put this method into alot more advanced code like:
SELECT TOP 100 white_subscriber.*, (housenumber) AS housenr, count(white_info.id) AS infocnt FROM white_subscriber LEFT JOIN white_info ON white_info.id = white_subscriber.id WHERE postalcode LIKE '0000__' GROUP BY white_subscriber.id, white_subscriber.category, white_subscriber.title, white_subscriber.firstname, white_subscriber.infix, white_subscriber.lastname, white_subscriber.streetname, white_subscriber.housenumber, white_subscriber.postalcode, white_subscriber.city, white_subscriber.phone, white_info.id ORDER BY postalcode,housenr
I self have made the code like this:
SELECT white_subscriber., (housenumber) AS housenr, count(white_info.id) AS infocnt FROM (SELECT TOP 100 white_subscriber., (housenumber) AS housenr, count(white_info.id) AS infocnt FROM (SELECT TOP 200 white_subscriber.*, (housenumber) AS housenr, count(white_info.id) AS infocnt FROM white_subscriber LEFT JOIN white_info ON white_info.id = white_subscriber.id
ORDER BY postalcode,housenr ASC) AS tbl1
ORDER BY postalcode,housenr DESC) AS tbl2
ORDER BY postalcode,housenr ASC
This code is needed to search the DB Phonebook, this code gives errors like:
- The column prefix 'white_subscriber' does not match with a table name or alias name used in the query
- - The column prefix 'white_info' does not match with a table name or alias name used in the query
Anyone know a solution or working order of this code then I would be very gratefull. Thanks in advance for all support.