OVH Cloud OVH Cloud

Question SQL ?

2 réponses
Avatar
Jeff
Bonjour voilà j'ai deux tables:

Table1 --> IdTache
Tache

Table2 --> IdOpération
IdTache
Sem01

Dans la Table1 : 1 Un test
2 Un autre Test

Dans la Table2 : 1 1 Oui

La code

Dim Record As Recordset
Dim Sql As String

Sql = "SELECT Table1.*, Table2.* FROM Table1, Table2 WHERE Table2.SEM01
= True AND Table2.IdTache = 1"

Set Record = CurrentDb.OpenRecordset(Sql)

With Record
If .RecordCount > 0 Then
.MoveLast
Do While Not .EOF
print .Fields!Table1.Tache
print .Fields!table2.idOperation

.MoveNext
Loop
End If
.Close
End With

Set Record = Nothing

j'obtient

1 Un test
1 Un test

comment faire pour ne pas répéter le recordset ??

Merci de votre aide @+ Jeff

2 réponses

Avatar
Daniel Carollo
Bonjour Jef!

Vous n'avez pas indique la jointure. Une formulation plus correcte serait:
Sql = "SELECT Table1.*, Table2.* FROM Table1 INNER JOIN Table2 ON
Table1.IdTache = Table2.IdTache WHERE Table2.SEM01 = True AND Table2.IdTache
= 1"
Voyez l'aide en ligne sur les jointures.

Bonne continuation.

Daniel :-)

Computing Technologies International - www.computing-tech.com - We
provide solutions...

"Jeff" wrote in message
news:3f1c0ddf$0$1357$
Bonjour voilà j'ai deux tables:

Table1 --> IdTache
Tache

Table2 --> IdOpération
IdTache
Sem01

Dans la Table1 : 1 Un test
2 Un autre Test

Dans la Table2 : 1 1 Oui

La code

Dim Record As Recordset
Dim Sql As String

Sql = "SELECT Table1.*, Table2.* FROM Table1, Table2 WHERE
Table2.SEM01

= True AND Table2.IdTache = 1"

Set Record = CurrentDb.OpenRecordset(Sql)

With Record
If .RecordCount > 0 Then
.MoveLast
Do While Not .EOF
print .Fields!Table1.Tache
print .Fields!table2.idOperation

.MoveNext
Loop
End If
.Close
End With

Set Record = Nothing

j'obtient

1 Un test
1 Un test

comment faire pour ne pas répéter le recordset ??

Merci de votre aide @+ Jeff




Avatar
Jeff
heu oui ces vrai

merci

"Daniel Carollo" a écrit dans le
message de news:
Bonjour Jef!

Vous n'avez pas indique la jointure. Une formulation plus correcte serait:
Sql = "SELECT Table1.*, Table2.* FROM Table1 INNER JOIN Table2 ON
Table1.IdTache = Table2.IdTache WHERE Table2.SEM01 = True AND
Table2.IdTache

= 1"
Voyez l'aide en ligne sur les jointures.

Bonne continuation.

Daniel :-)

Computing Technologies International - www.computing-tech.com - We
provide solutions...

"Jeff" wrote in message
news:3f1c0ddf$0$1357$
Bonjour voilà j'ai deux tables:

Table1 --> IdTache
Tache

Table2 --> IdOpération
IdTache
Sem01

Dans la Table1 : 1 Un test
2 Un autre Test

Dans la Table2 : 1 1 Oui

La code

Dim Record As Recordset
Dim Sql As String

Sql = "SELECT Table1.*, Table2.* FROM Table1, Table2 WHERE
Table2.SEM01

= True AND Table2.IdTache = 1"

Set Record = CurrentDb.OpenRecordset(Sql)

With Record
If .RecordCount > 0 Then
.MoveLast
Do While Not .EOF
print .Fields!Table1.Tache
print .Fields!table2.idOperation

.MoveNext
Loop
End If
.Close
End With

Set Record = Nothing

j'obtient

1 Un test
1 Un test

comment faire pour ne pas répéter le recordset ??

Merci de votre aide @+ Jeff