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

Recordset SQL: help for a WHERE with multiple fields

New Here ,
Jul 09, 2007 Jul 09, 2007
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
381
Translate
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
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
Translate
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

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

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


Translate
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
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
>
>


Translate
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