Home > Mobile >  Laravel 9 Query Builder MS Access SQL Conversion
Laravel 9 Query Builder MS Access SQL Conversion

Time:10-26

I have this query for SQL accessing an old Access DB. I need to convert it to use query builder. I don't need a model, just to be able to use QB to query the db.

sql = "SELECT tblSU.Site, tlkpSUDesc.ESR_SUcat, tlkpSUDesc.ESR_SUcatdisp, tlkpSUDesc.SUDesc, tlkpSUTyp.SUTyp, tblSU.SUNum"
sql = sql & " FROM tlkpSUTyp RIGHT JOIN (tlkpSUDesc RIGHT JOIN tblSU ON tlkpSUDesc.SUDescCode = tblSU.SUDescCode) ON tlkpSUTyp.SUTypCode = tblSU.SUTypCode"
sql = sql & " WHERE (((tblSU.Site)='" & request("Site") & "') AND ((tlkpSUDesc.ESR_SUcat)='" & request("Crit") & "') AND (Not (tblSU.SUTypCode)='GEN'))"
sql = sql & " ORDER BY tblSU.Site, tlkpSUDesc.ESR_SUcatdisp, tblSU.SUDescCode, CDbl(IIf(InStr([tblSU]![SUNum],'-'),Left([tblSU]![SUNum],Len([tblSU]![SUNum])-2),[tblSU]![SUNum]))"

CodePudding user response:

Use DB::raw('your sql query');

  • Related