Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Recordset SQL: help for a WHERE with multiple fields

New Here ,
Jul 09, 2007 Jul 09, 2007

Copy link to clipboard

Copied

Ive a problem with Dreamweaver and SQL query.
This query works:

SELECT *
FROM table
WHERE table.field1 LIKE %MMColParam%

The MMColParam is a Request.Form("variable") from a previous form in ASP page.
But if i try to extend to two or more fields the WHERE function with OR, like the following query, i receive a syntax error!

SELECT *
FROM table
WHERE table.field1 LIKE %MMColParam% OR table.field2 LIKE %MMColParam%

Whats the right syntax format for this type of query?

Thanx a lot
TOPICS
Server side applications

Views

379
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 09, 2007 Jul 09, 2007

Copy link to clipboard

Copied

maybe depends on the database you use

possible solution:
SELECT *
FROM table
WHERE table.field1 LIKE '%' + MMColParam + '%' OR table.field2 LIKE '%' + MMColParam + '%'

hope this helps
sebastian

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 09, 2007 Jul 09, 2007

Copy link to clipboard

Copied


Not sure which db but try adding ('s as below

SELECT *
FROM table
WHERE (table.field1 LIKE %MMColParam%) OR (table.field2 LIKE
%MMColParam%)


Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 09, 2007 Jul 09, 2007

Copy link to clipboard

Copied

LATEST
Syntax errors are often caused by incorrect field types. Check that both
database fields are exactly the same type.

--
Paul Whitham
Certified Dreamweaver MX2004 Professional
Adobe Community Expert - Dreamweaver

Valleybiz Internet Design
www.valleybiz.net

"promastermz" <webforumsuser@macromedia.com> wrote in message
news:f6sqap$399$1@forums.macromedia.com...
> Ive a problem with Dreamweaver and SQL query.
> This query works:
>
> SELECT *
> FROM table
> WHERE table.field1 LIKE %MMColParam%
>
> The MMColParam is a Request.Form("variable") from a previous form in ASP
> page.
> But if i try to extend to two or more fields the WHERE function with OR,
> like
> the following query, i receive a syntax error!
>
> SELECT *
> FROM table
> WHERE table.field1 LIKE %MMColParam% OR table.field2 LIKE %MMColParam%
>
> Whats the right syntax format for this type of query?
>
> Thanx a lot
>
>


Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines