Recent

Author Topic: [SOLVED] how subtract 2 from all the grades?  (Read 12666 times)

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: how subtract 2 from all the grades?
« Reply #30 on: March 06, 2016, 06:55:15 am »
which database backend you are using? and is the quote char in the of true a type error?
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Delphilearner

  • New Member
  • *
  • Posts: 26
Re: how subtract 2 from all the grades?
« Reply #31 on: March 06, 2016, 11:43:15 am »
which database backend you are using? and is the quote char in the of true a type error?

my database is Access

this code working

UPDATE t2 SET math =(math-2)

but when i add the condition i have an error

UPDATE t2 SET math =(math-2) WHERE T1.K=True // the error in T1.k=true



taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: how subtract 2 from all the grades?
« Reply #32 on: March 06, 2016, 11:55:09 am »
which database backend you are using? and is the quote char in the of true a type error?

my database is Access

this code working

UPDATE t2 SET math =(math-2)

but when i add the condition i have an error

UPDATE t2 SET math =(math-2) WHERE T1.K=True // the error in T1.k=true
You can't use T1 in your where clause unless it is part of the main command you have to make it a subquery something along the lines of
Code: SQL  [Select][+][-]
  1.   UPDATE t2 SET math =(math-2) WHERE EXISTS(SELECT 1 FROM T1 WHERE T1.ID = T2.ID AND T1.K =TRUE)
  2.  
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Delphilearner

  • New Member
  • *
  • Posts: 26
Re: how subtract 2 from all the grades?
« Reply #33 on: March 06, 2016, 05:25:43 pm »
thank you very much taazz

but you select 1 in ypor code what does it mean?

EXISTS(SELECT 1 FROM T1 WHERE T1.ID = T2.ID AND T1.K =TRUE

solved
« Last Edit: March 06, 2016, 05:29:32 pm by Delphilearner »

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: how subtract 2 from all the grades?
« Reply #34 on: March 06, 2016, 06:19:43 pm »
thank you very much taazz

but you select 1 in ypor code what does it mean?

EXISTS(SELECT 1 FROM T1 WHERE T1.ID = T2.ID AND T1.K =TRUE

solved
I do not need anything specific returned from the table in question, I simply select to return the number 1 once for every record found, it can be any dummy value.
« Last Edit: March 06, 2016, 06:24:13 pm by taazz »
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Delphilearner

  • New Member
  • *
  • Posts: 26
Re: how subtract 2 from all the grades?
« Reply #35 on: March 07, 2016, 10:33:56 am »
thank you very much

solved

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: how subtract 2 from all the grades?
« Reply #36 on: March 07, 2016, 10:56:23 am »
Could you edit the title of your thread to include SOLVED? Other users cannot do this for a thread you started.

 

TinyPortal © 2005-2018