Serious SQL HELP!

Re: Serious SQL HELP!

The function was originally used in PHP-PGSQL integration. We now are migrating to SQL server for testing. The commented part was taken out from a working PGSQL- SQL query like this one:


$query = "SELECT DISTINCT ON (products.otherproduct1id) mallcats.mallcatid, mallcatlocations.mallcatlocationsid, products.otherproduct1id, products.productname
            FROM mallcatlocations INNER JOIN productgroupbycat ON
            mallcatlocations.mallcatlocationsid = productgroupbycat.mallcatlocationid INNER JOIN
            products ON (productgroupbycat.productid = products.otherproduct1id) AND (productgroupbycat.productid = products.productid)
            INNER JOIN mallcats ON mallcatlocations.mallcatid = mallcats.mallcatid
            WHERE " . $que; 


The above query works like a charm. MSSQL - SQL lingo does not support it, and this one is becoming a mind bender since i am not too savvy when it comes to complex SQL's