SQL Question

M

Mauricio Freitas

Hi!

I have two tables and I want to search a text within two text fields, like
this:

SELECT DISTINCTROW Table1.chave1
FROM Table1 INNER JOIN Table2 ON Table1.chave1 = Table2.Chave1
WHERE (((Table1.texto1)="item")) OR (((Table2.Texto2)="item"));

Instead of = I want to use "contain". If either table1.text1 or table2.text2
contains a keyword I want to return the table1.chave1

What's the clause I'll have to use to replace the "=" sign in my WHERE
expression?

Thanks

Mauricio
 
D

Duane Hookom

If I understand correctly, you are looking for:
SELECT DISTINCTROW Table1.chave1
FROM Table1 INNER JOIN Table2 ON Table1.chave1 = Table2.Chave1
WHERE Table1.texto1 Like "*item*" OR Table2.Texto2 Like "*item*";
 
M

Mauricio Freitas

Mauricio Freitas said:
Hi!

I have two tables and I want to search a text within two text fields, like
this:

SELECT DISTINCTROW Table1.chave1
FROM Table1 INNER JOIN Table2 ON Table1.chave1 = Table2.Chave1
WHERE (((Table1.texto1)="item")) OR (((Table2.Texto2)="item"));

Instead of = I want to use "contain". If either table1.text1 or table2.text2
contains a keyword I want to return the table1.chave1

What's the clause I'll have to use to replace the "=" sign in my WHERE
expression?

Thanks

Mauricio

Never mind. Found the answer:

SELECT DISTINCTROW Table1.chave1
FROM Table1 INNER JOIN Table2 ON Table1.chave1 = Table2.Chave1
WHERE (((Table1.texto1) Like "*mainfr*")) OR (((Table2.Texto2) Like
"*mainfr*"));


Thanks!
 
V

Van T. Dinh

Try:

SELECT DISTINCTROW Table1.chave1
FROM Table1 INNER JOIN Table2
ON Table1.chave1 = Table2.Chave1
WHERE (Table1.texto1 LIKE "*item*")
OR (Table2.Texto2 LIKE "*item*")

HTH
Van T. Dinh
MVP (Access)
 
J

John Spencer (MVP)

In Access.

WHERE Table1.Texto1 LIKE "*Item*" or Table2.Texto2 Like "*Item*"
 
Top