0

I am currently working on wild card matching in URL. The argument is given by user in the URL should match with the values in database. If the argument is like PDR-*-BC,this should match all the values.

I replaced the * with % in php code.and added LIKE in SQL query as,

"Where tablename.columnname LIKE ."'mysql_real_escape_string($arg,$sql)'"" .

If the user give "PDR-NRT-BC" in URL ,the sql query with '=' or LIKE would fetch same match, but when argument has white space, LIKE wont return any value.

But for wild card match "LIKE" will help for related matches.

I have to do both conditions (single arg and wild card) in same sql query.

Is there any way to do this?

James Z
  • 12,209
  • 10
  • 24
  • 44
  • How would you know it is *exact*? What about using `OR`? – Sougata Bose Jul 10 '15 at 06:45
  • 1
    I removed the sql-server tag, just as it isn't a sql-server specific question. – Ionic Jul 10 '15 at 06:48
  • possible duplicate of [Difference between LIKE and = in MYSQL?](http://stackoverflow.com/questions/1003381/difference-between-like-and-in-mysql) – SpongePablo Jul 10 '15 at 07:01
  • it has been asked many times http://stackoverflow.com/questions/1003381/difference-between-like-and-in-mysql http://stackoverflow.com/questions/543580/equals-vs-like https://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html – SpongePablo Jul 10 '15 at 07:01
  • This is not like asking difference between LIKE and = .My question is different. – Nandhakumar Sellappan Jul 10 '15 at 07:09

1 Answers1

0

When there are no wildcards "LIKE" is the same as "=". And in SQL Server I am pretty sure the execution plans are the same.

JohnS
  • 1,942
  • 1
  • 13
  • 16