instead to use and ... and a....and in sql

User avatar
sal21
PlatinumLounger
Posts: 4368
Joined: 26 Apr 2010, 17:36

instead to use and ... and a....and in sql

Post by sal21 »

Instaded to use a variuos AND statement in a where condition on field TEST i can use the statement

... where TEST in (ttt,iii,iuy)...eccc

Tks.

User avatar
HansV
Administrator
Posts: 78592
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: instead to use and ... and a....and in sql

Post by HansV »

where TEST in ('ttt','iii','iuy')

is the same as

WHERE TEST='ttt' OR TEST='iii' OR TEST='iuy'

For an AND condition, you have to use

WHERE ThisField='ttt' AND ThatField='iii' AND OtherField='iuy'
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4368
Joined: 26 Apr 2010, 17:36

Re: instead to use and ... and a....and in sql

Post by sal21 »

HansV wrote:where TEST in ('ttt','iii','iuy')

is the same as

WHERE TEST='ttt' OR TEST='iii' OR TEST='iuy'

For an AND condition, you have to use

WHERE ThisField='ttt' AND ThatField='iii' AND OtherField='iuy'
OK... tks for note. :thankyou:

on fly... i need to update the filed MESE from DATA_CREAZ only with a month in format MM...

example:
DATA_CREAZ=12/12/2010 MESE=12

note:
DATA_CREAZ is formatted as Date MESE is Text
see the image vattached
You do not have the required permissions to view the files attached to this post.
Last edited by sal21 on 26 Oct 2010, 13:58, edited 1 time in total.

User avatar
HansV
Administrator
Posts: 78592
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: instead to use and ... and a....and in sql

Post by HansV »

You can update to

Format([DATA_CREAZ], "mm")

Note the quotes around the format strong "mm".
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4368
Joined: 26 Apr 2010, 17:36

Re: instead to use and ... and a....and in sql

Post by sal21 »

HansV wrote:where TEST in ('ttt','iii','iuy')

is the same as

WHERE TEST='ttt' OR TEST='iii' OR TEST='iuy'

For an AND condition, you have to use

WHERE ThisField='ttt' AND ThatField='iii' AND OtherField='iuy'
... base the IN condition how to insert in Field1 the two condition:

Field1=" " or IsNull

User avatar
HansV
Administrator
Posts: 78592
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: instead to use and ... and a....and in sql

Post by HansV »

You'd use

WHERE Field1=" " Or Field1 Is Null

(are you sure that you mean a space?)
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4368
Joined: 26 Apr 2010, 17:36

Re: instead to use and ... and a....and in sql

Post by sal21 »

HansV wrote:You'd use

WHERE Field1=" " Or Field1 Is Null

(are you sure that you mean a space?)
YES!

During the rs(I) looping i se a var (refered the current record Var=" ")...

User avatar
sal21
PlatinumLounger
Posts: 4368
Joined: 26 Apr 2010, 17:36

Re: instead to use and ... and a....and in sql

Post by sal21 »

HansV wrote:You'd use

WHERE Field1=" " Or Field1 Is Null

(are you sure that you mean a space?)

Based thi condition how to integrate the condition of field1 in existing SQL string?

SQL = "SELECT * FROM [CC_DAILY] WHERE [TIPO_DATO]='" & TEST_TIPO & "' AND COD_FIDO <> " & TEST_TIPO_CTR_2 & " AND CTR IN (" & TEST_TIPO_CTR & "," & TEST_TIPO_CTR_1 & ") AND INATT=" & INATTIVO & " ORDER BY COD_SPORT_RAD, COD_CONTO"

User avatar
HansV
Administrator
Posts: 78592
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: instead to use and ... and a....and in sql

Post by HansV »

SQL = "SELECT * FROM [CC_DAILY] WHERE [TIPO_DATO]='" & TEST_TIPO & "' AND COD_FIDO <> " & TEST_TIPO_CTR_2 & " AND CTR IN (" & TEST_TIPO_CTR & "," & TEST_TIPO_CTR_1 & ") AND INATT=" & INATTIVO & " AND (Field1=" " Or Field1 Is Null) ORDER BY COD_SPORT_RAD, COD_CONTO"
Best wishes,
Hans