FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour TDolphin got error MySql/1052 Column 'deleted' is ambiguous
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
TDolphin got error MySql/1052 Column 'deleted' is ambiguous
Posted: Thu Sep 17, 2015 09:56 AM
Dear All,

I have some problem with duplicated field (deleted, it are in all table to identify deleted status). I open table with relation, when I delete a record but it show error as below.
MYSQL/1052 Column 'deleted' in field list is ambiguous

I open with this command
Code (fw): Select all Collapse
Function OpenDb(cTable, cQuery, cOrderBy, cTable1, cRelation1, cTable2, cRelation2, cTable3, cRelation3 )
local cFileName, cFile, cFullName
local cSql, oErr, oDb
.....
        cSql := "SELECT * FROM "+lower(cTable)+ ;
                        iif(!empty(cTable1)," LEFT JOIN "+lower(cTable1)+" ON "+lower(cRelation1),"")+;
                        iif(!empty(cTable2)," LEFT JOIN "+lower(cTable2)+" ON "+lower(cRelation2),"")+;
                        iif(!empty(cTable3)," LEFT JOIN "+lower(cTable3)+" ON "+lower(cRelation3),"")+;
                        iif(!empty(cQuery)," WHERE "+cQuery+" AND deleted<>'Y'","")+;   // 
                        iif(!empty(cOrderBy)," ORDER BY "+cOrderBy,"")
                        
    oDb := MEMVAR->oServer:Query(cSql)
return oDb

I use TDolphin to access MySql Db.
​When I replace 'Y' in deleted field as
Code (fw): Select all Collapse
oDb:deleted := 'Y'

it show an error, how do I fix it? How to specific table with field in relation condition?

Thanks in advance for help and any idea.
Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 46
Joined: Tue May 07, 2013 07:27 PM
Re: TDolphin got error MySql/1052 Column 'deleted' is ambiguous
Posted: Fri Sep 18, 2015 11:07 AM
Dutch, buen dia

Lo que debes hacer es referenciar la columna a la tabla, de la siguiente manera

Code (fw): Select all Collapse
Function OpenDb(cTable, cQuery, cOrderBy, cTable1, cRelation1, cTable2, cRelation2, cTable3, cRelation3 )
local cFileName, cFile, cFullName
local cSql, oErr, oDb
.....
        cSql := "SELECT * FROM "+lower(cTable)+ ;
                        iif(!empty(cTable1)," LEFT JOIN "+lower(cTable1)+" ON "+lower(cRelation1),"")+;
                        iif(!empty(cTable2)," LEFT JOIN "+lower(cTable2)+" ON "+lower(cRelation2),"")+;
                        iif(!empty(cTable3)," LEFT JOIN "+lower(cTable3)+" ON "+lower(cRelation3),"")+;
                        iif(!empty(cQuery)," WHERE "+cQuery+" AND "+lower(cTable)+".deleted<>'Y'","")+;   // 
                        iif(!empty(cOrderBy)," ORDER BY "+cOrderBy,"")
                        
    oDb := MEMVAR->oServer:Query(cSql)
return oDb


Espero te sirva Saludos Pedro Lerda
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: TDolphin got error MySql/1052 Column 'deleted' is ambiguous
Posted: Fri Sep 18, 2015 01:36 PM

Yo uso esta función para todos los comandos mesa de base de datos abierta, será fácil cambiar en uno y efecto a todos.

Thanks,

Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)

Continue the discussion