1.11M Members

Search query

 
0
 

Hallo,

I am trying to fix my mysql search query:

 $data = mysql_query("SELECT * FROM static_content WHERE upper(image) or upper(title) or upper(content) LIKE'%$find%'"); 

Please help me to fix it. Is it correct?

I mean where column image (change to upper case) or column title (change to upper case) or column content (change to upper case) like the data that I input in the search box (the code before it already change it to uppercase).

 
0
 

No, it's not correct. You need LIKE after every column, unless you concatenate them first.

 
0
 

How to concatenate them ? like where ?

 
0
 

I read the guide, I still do not understand how to apply it to my query. I guess I just use this one:

 $data = mysql_query("SELECT * FROM static_content WHERE upper(image) LIKE'%$find%' or upper(title) LIKE'%$find%' or upper(content) LIKE'%$find%'"); 

Is that correct?

 
0
 

Is that correct?

Yes.

Apart from that. In most cases comparisons in queries are case-insensitive, so you could probably do without UPPER()

 
0
 

Thanks. I probably will close this forum.

If anyone can help me with this one would great:

another related thread

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article