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

search engine

Participant ,
Dec 12, 2011 Dec 12, 2011

Dear all,

I have below parameter for search engine, it search only in Name, I have to make it also to search in WebLink?! How to do that?!

SELECT *

FROM WebSite

WHERE Name = MMColParam1

ORDER BY NameID DESC

Please your help ASAP.

Thanks and regards,

FAIZ ALI

TOPICS
Server side applications
803
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 ,
Dec 13, 2011 Dec 13, 2011

SELECT *

FROM WebSite

WHERE Name = MMColParam1 OR

WebLink = MMColParam1

ORDER BY NameID DESC

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
Participant ,
Dec 13, 2011 Dec 13, 2011

NO,It didn't work?!

Syntax error in query expression 'WebName LIKE ? OR WebLink LIKE %MMColParam1% and UserID = ?'.

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
Participant ,
Dec 14, 2011 Dec 14, 2011

This is Solution

SELECT *

FROM WebName

WHERE (WebName LIKE %MMColParam1%  OR WebLink LIKE %MMColParam2% ) and UserID = MMColParam

ORDER BY WebName DESC

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 ,
Dec 14, 2011 Dec 14, 2011

Yes. That's a completely different query than what you originally asked for thought. Right? Your original query did not use the LIKE predicate or contain the UserID.

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
Community Beginner ,
Dec 14, 2011 Dec 14, 2011

Just so you know, it would be a good idea to give your MMColParam variables a meaningful name rather than the default Dreamweaver name, it will help you keep track of which variables you're accessing in you queries. Bregent is correct, you wanted to search the same variable by two different fields originally, so an OR would give you that result. If you wanted to match values exactly you would use:

SELECT *

FROM WebName

WHERE WebName = meaningfulVariableName AND WebLink = anotherMeaningfulVariableName

ORDER BY WebName DESC

Your current solution will give you results that include characters before and after your query string, so if variable1 = "website" it would also return "mywebsite", "websiteforyou", etc.

I hope this helps, the only reason I am blathering like this is that I have much less hair from trying to figure all this stuff out and I thought I'd save you some of yours :-).

Tom

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
Participant ,
Dec 16, 2011 Dec 16, 2011
LATEST

Thank you for your help

bregent,illbehere

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