SELECT a.*, IF( a.bprice != "",a.bprice,a.price ) price ,a.price AS aprice, a.bprice AS bprice, a.imgmain AS img_name ,c.title AS category_name, c.id AS categid, c.itemtype AS catitemtype,mk.id AS mkid,mk.name AS make_name,md.id AS mdid,md.name AS model_name,bt.id AS btid,bt.name AS bodytype_name,dr.id AS drid,dr.name AS drive_name,ecl.id AS eclid,ecl.name AS extcolor_name, ecl.image AS extcolor_image, ecl.csscode AS csscode_color,tr.id AS trid,tr.name AS trans_name, tr.code AS trans_code,fl.id AS flid,fl.name AS fuel_name, fl.code AS fuel_code,user.id AS userwid,user.name AS user_name, user.username AS user_username, user.email AS user_email,expusercountry.id AS expusercountrywid,expuserstate.id AS expuserstatewid,expusercity.id AS expusercitywid,expuser.id AS expuser_id,expuser.lastname AS expuser_lastname, expuser.companyname AS expuser_companyname,expuser.street AS expuser_street,expuser.phone AS expuser_phone,expuser.web AS expuser_web, expuser.logo AS expuser_logo,expuser.headerimg AS expuser_headerimg, expuser.customimg AS expuser_customimg,expuser.zipcode AS expuser_zipcode, expuser.fax AS expuser_fax,expuser.mobphone AS expuser_mobphone, expuser.userinfo AS expuser_userinfo,expuser.utop AS expuser_utop, expuser.ucommercial AS expuser_ucommercial,expuser.uspecial AS expuser_uspecial,expusercountry.name AS expuser_country, expusercity.city_name AS expuser_city,expuserstate.name AS expuser_state,expuser.latitude AS expuser_latitude,expuser.longitude AS expuser_longitude,cnt.id AS cntid,cnt.name AS cnt_name,st.id AS stid,st.name AS st_name,ct.id AS ctid,ct.city_name AS ct_name,ag.title AS access_level
FROM #__expautos_admanager as a
LEFT JOIN #__expautos_categories AS c ON c.id = a.catid
LEFT JOIN #__expautos_make AS mk ON mk.id = a.make
LEFT JOIN #__expautos_model AS md ON md.id = a.model
LEFT JOIN #__expautos_bodytype AS bt ON bt.id = a.bodytype
LEFT JOIN #__expautos_drive AS dr ON dr.id = a.drive
LEFT JOIN #__expautos_color AS ecl ON ecl.id = a.extcolor
LEFT JOIN #__expautos_trans AS tr ON tr.id = a.trans
LEFT JOIN #__expautos_fuel AS fl ON fl.id = a.fuel
LEFT JOIN #__users AS user ON user.id = a.user
LEFT JOIN #__expautos_expuser AS expuser ON expuser.userid = a.user
LEFT JOIN #__expautos_country AS expusercountry ON expusercountry.id = expuser.country
LEFT JOIN #__expautos_state AS expuserstate ON expuserstate.id = expuser.expstate
LEFT JOIN #__expautos_cities AS expusercity ON expusercity.id = expuser.city
LEFT JOIN #__expautos_country AS cnt ON cnt.id = a.country
LEFT JOIN #__expautos_state AS st ON st.id = a.expstate
LEFT JOIN #__expautos_cities AS ct ON ct.id = a.city
LEFT JOIN #__viewlevels AS ag ON ag.id = a.access AND ag.id = c.access
WHERE a.user != "" AND a.user > 0 AND c.published = 1 AND c.access IN (1,1) AND a.state=1 AND a.user = 1218
ORDER BY a.ftop DESC, a.creatdate desc
SELECT a.*, IF( a.bprice != "",a.bprice,a.price ) price ,a.price AS aprice, a.bprice AS bprice, a.imgmain AS img_name ,c.title AS category_name, c.id AS categid, c.itemtype AS catitemtype,mk.id AS mkid,mk.name AS make_name,md.id AS mdid,md.name AS model_name,bt.id AS btid,bt.name AS bodytype_name,dr.id AS drid,dr.name AS drive_name,ecl.id AS eclid,ecl.name AS extcolor_name, ecl.image AS extcolor_image, ecl.csscode AS csscode_color,tr.id AS trid,tr.name AS trans_name, tr.code AS trans_code,fl.id AS flid,fl.name AS fuel_name, fl.code AS fuel_code,user.id AS userwid,user.name AS user_name, user.username AS user_username, user.email AS user_email,expusercountry.id AS expusercountrywid,expuserstate.id AS expuserstatewid,expusercity.id AS expusercitywid,expuser.id AS expuser_id,expuser.lastname AS expuser_lastname, expuser.companyname AS expuser_companyname,expuser.street AS expuser_street,expuser.phone AS expuser_phone,expuser.web AS expuser_web, expuser.logo AS expuser_logo,expuser.headerimg AS expuser_headerimg, expuser.customimg AS expuser_customimg,expuser.zipcode AS expuser_zipcode, expuser.fax AS expuser_fax,expuser.mobphone AS expuser_mobphone, expuser.userinfo AS expuser_userinfo,expuser.utop AS expuser_utop, expuser.ucommercial AS expuser_ucommercial,expuser.uspecial AS expuser_uspecial,expusercountry.name AS expuser_country, expusercity.city_name AS expuser_city,expuserstate.name AS expuser_state,expuser.latitude AS expuser_latitude,expuser.longitude AS expuser_longitude,cnt.id AS cntid,cnt.name AS cnt_name,st.id AS stid,st.name AS st_name,ct.id AS ctid,ct.city_name AS ct_name,ag.title AS access_level
FROM #__expautos_admanager as a
LEFT JOIN #__expautos_categories AS c ON c.id = a.catid
LEFT JOIN #__expautos_make AS mk ON mk.id = a.make
LEFT JOIN #__expautos_model AS md ON md.id = a.model
LEFT JOIN #__expautos_bodytype AS bt ON bt.id = a.bodytype
LEFT JOIN #__expautos_drive AS dr ON dr.id = a.drive
LEFT JOIN #__expautos_color AS ecl ON ecl.id = a.extcolor
LEFT JOIN #__expautos_trans AS tr ON tr.id = a.trans
LEFT JOIN #__expautos_fuel AS fl ON fl.id = a.fuel
LEFT JOIN #__users AS user ON user.id = a.user
LEFT JOIN #__expautos_expuser AS expuser ON expuser.userid = a.user
LEFT JOIN #__expautos_country AS expusercountry ON expusercountry.id = expuser.country
LEFT JOIN #__expautos_state AS expuserstate ON expuserstate.id = expuser.expstate
LEFT JOIN #__expautos_cities AS expusercity ON expusercity.id = expuser.city
LEFT JOIN #__expautos_country AS cnt ON cnt.id = a.country
LEFT JOIN #__expautos_state AS st ON st.id = a.expstate
LEFT JOIN #__expautos_cities AS ct ON ct.id = a.city
LEFT JOIN #__viewlevels AS ag ON ag.id = a.access AND ag.id = c.access
WHERE a.user != "" AND a.user > 0 AND c.published = 1 AND c.access IN (1,1) AND a.state=1 AND a.user = 1218
ORDER BY a.ftop DESC, a.creatdate desc
SELECT a.*, IF( a.bprice != "",a.bprice,a.price ) price ,a.price AS aprice, a.bprice AS bprice, a.imgmain AS img_name ,c.title AS category_name, c.id AS categid, c.itemtype AS catitemtype,mk.id AS mkid,mk.name AS make_name,md.id AS mdid,md.name AS model_name,bt.id AS btid,bt.name AS bodytype_name,dr.id AS drid,dr.name AS drive_name,ecl.id AS eclid,ecl.name AS extcolor_name, ecl.image AS extcolor_image, ecl.csscode AS csscode_color,tr.id AS trid,tr.name AS trans_name, tr.code AS trans_code,fl.id AS flid,fl.name AS fuel_name, fl.code AS fuel_code,user.id AS userwid,user.name AS user_name, user.username AS user_username, user.email AS user_email,expusercountry.id AS expusercountrywid,expuserstate.id AS expuserstatewid,expusercity.id AS expusercitywid,expuser.id AS expuser_id,expuser.lastname AS expuser_lastname, expuser.companyname AS expuser_companyname,expuser.street AS expuser_street,expuser.phone AS expuser_phone,expuser.web AS expuser_web, expuser.logo AS expuser_logo,expuser.headerimg AS expuser_headerimg, expuser.customimg AS expuser_customimg,expuser.zipcode AS expuser_zipcode, expuser.fax AS expuser_fax,expuser.mobphone AS expuser_mobphone, expuser.userinfo AS expuser_userinfo,expuser.utop AS expuser_utop, expuser.ucommercial AS expuser_ucommercial,expuser.uspecial AS expuser_uspecial,expusercountry.name AS expuser_country, expusercity.city_name AS expuser_city,expuserstate.name AS expuser_state,expuser.latitude AS expuser_latitude,expuser.longitude AS expuser_longitude,cnt.id AS cntid,cnt.name AS cnt_name,st.id AS stid,st.name AS st_name,ct.id AS ctid,ct.city_name AS ct_name,ag.title AS access_level
FROM #__expautos_admanager as a
LEFT JOIN #__expautos_categories AS c ON c.id = a.catid
LEFT JOIN #__expautos_make AS mk ON mk.id = a.make
LEFT JOIN #__expautos_model AS md ON md.id = a.model
LEFT JOIN #__expautos_bodytype AS bt ON bt.id = a.bodytype
LEFT JOIN #__expautos_drive AS dr ON dr.id = a.drive
LEFT JOIN #__expautos_color AS ecl ON ecl.id = a.extcolor
LEFT JOIN #__expautos_trans AS tr ON tr.id = a.trans
LEFT JOIN #__expautos_fuel AS fl ON fl.id = a.fuel
LEFT JOIN #__users AS user ON user.id = a.user
LEFT JOIN #__expautos_expuser AS expuser ON expuser.userid = a.user
LEFT JOIN #__expautos_country AS expusercountry ON expusercountry.id = expuser.country
LEFT JOIN #__expautos_state AS expuserstate ON expuserstate.id = expuser.expstate
LEFT JOIN #__expautos_cities AS expusercity ON expusercity.id = expuser.city
LEFT JOIN #__expautos_country AS cnt ON cnt.id = a.country
LEFT JOIN #__expautos_state AS st ON st.id = a.expstate
LEFT JOIN #__expautos_cities AS ct ON ct.id = a.city
LEFT JOIN #__viewlevels AS ag ON ag.id = a.access AND ag.id = c.access
WHERE a.user != "" AND a.user > 0 AND c.published = 1 AND c.access IN (1,1) AND a.state=1 AND a.user = 1218
ORDER BY a.ftop DESC, a.creatdate desc