jws2bay
asked on
MySQL statement using LIKE
I am working on a mySQL/PHP web server. I currently have the following statement:
"SELECT * FROM Products WHERE Part_no LIKE %s ORDER BY Finish ASC", GetSQLValueString($colname _RS_group . "%", "text")
It is sorting data with Part_no similar to:
SDCD38CH
SDCD38CHK
SDCD38PB
SDCD12CH
The search term pulled from the URL is SDCD38. The result I currently get is:
SDCD38CH
SDCD38CHK
SDCD38PB
I want to filter out any Part_no ending in K so that I get
SDCD38CH
SDCD38PB
How can I modify the LIKE term to block any Part_no ending in K?
"SELECT * FROM Products WHERE Part_no LIKE %s ORDER BY Finish ASC", GetSQLValueString($colname
It is sorting data with Part_no similar to:
SDCD38CH
SDCD38CHK
SDCD38PB
SDCD12CH
The search term pulled from the URL is SDCD38. The result I currently get is:
SDCD38CH
SDCD38CHK
SDCD38PB
I want to filter out any Part_no ending in K so that I get
SDCD38CH
SDCD38PB
How can I modify the LIKE term to block any Part_no ending in K?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Bernard,
Agreed. I'll get it down to the specific field after I have the page working.
Any ideas how to write a LIKE and does not end with K?
Agreed. I'll get it down to the specific field after I have the page working.
Any ideas how to write a LIKE and does not end with K?
ASKER
Ryan, That's it - works like it should. Thank you for the help.
Bernard, Thanks for the comment.
Bernard, Thanks for the comment.
Why? Just figure that your select * works fine on your table with 10 fields of at most 10 bytes each, and that at a later stage one field is added with variable length more than 10K on average (eg, text from a web page or image)... everybody will be puzzled at the sudden drop in performance (best case) or time-out on script (frequent), or (worse) a db ctash...