SQL Question

  • Thread starter Thread starter Mauricio Freitas
  • Start date Start date
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
 
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*";
 
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!
 
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)
 
Back
Top